opengl: maintaining colour when using lighting

This is a discussion on opengl: maintaining colour when using lighting within the Game Programming forums, part of the General Programming Boards category; Hey, I just wondered how I can maintain the colours of the objects in my scene, as when i add ...

opengl: maintaining colour when using lighting

Hey, I just wondered how I can maintain the colours of the objects in my scene, as when i add lighting, everything just goes like greyscale. I have things like brown boxes and green grass etc. and it all ends up grey/blue/black kind of colours.

I know theres the thing about the colour of lights in opengl, only returning that colour or something, but ive played about and cant seem to figure it. Any ideas? Cheers

Look into glMaterial and glColorMaterial on MSDN. Its been a while since I've used them but how they basically work is you can call glMaterial right before you draw your object and that sets what colors your object should reflect. glColorMaterial allows color tracking, which basically just means OpenGL sets the material properties (what colors of the light the object reflects) whenever you set your color. I would suggest using glColorMaterial because it is easier, and when you get drawing a lot of stuff its faster.

go to msdn to read up on how to use it (it explians it better than I can )