Turning on lighting renders scene in greyscale!

Yeh it’s a bit of a weird one. I must be doing something dumb.

I started off the program by rendering my scene as a mesh using GL_LINE_STRIP in green to get a feel for the contours and it all looked great. I then switched to GL_TRIANGLE_STRIP in preparation for shading and obviously with that I get one massive green blob.

I then moved on to calculating normals and finally defining my light sources and then switching on the lights. The lights are defined as

GLfloat ambient[] = {0.5,0.5,0.5,1.0};
GLfloat diffuse[] = {0.8,0.8,0.8,1.0};
GLfloat lightpos1[] = {-40.0,100.0,-10.0,1.0};
GLfloat lightpos2[] = {40.0,100.0,80.0,1.0}; 

What’s weird is that it the shading all works nicely and it fills all the polygons as they should be, but in greyscale! It’s like my specification to draw the polygons in green is completely ignored. As soon as I turn off the lights, then it draws in green again but with no shading, which is obviously pointless! TIA for any help.

you need to specify green color in material properties.
sounds like you don’t set any material attributes.

or simply use glEnable(GL_COLOR_MATERIAL);

Thanks for the replies guys.

OK I tried enabling COLOR_MATERIAL but now it draws in green with no shading even though lighting is on.

strange. probably a bug in your code.
beware of the value of ambient light, it should be kept black.

Thanks dude. You were right. It was the black. But I set it what most of the examples have had it as. Like 0.5ish across the RGBs. Anyway, set them to zero and it I can see the green now. Thanks man.

How do I indicate this thread is resolved?

write how you fixed the problem and post the correct code.