Archived

This topic is now archived and is closed to further replies.

Lighting/color problem - beginner

This topic is 5128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have a gold colored object in the center but when I add a floor below it and a wall behind it, the object also takes on the colors of the floor/wall and becomes darker, no longer gold. The floor also changes to blue if I insert a blue object. I''ve tried tweeking several things in the lighting and coloring but with no success. my steps: 1. enable lighting 2. set material of floor, texture map the floor 3. set material/color of gold object -lighting and colormaterial is enabled throughout. what could I be doing wrong? Should i be enabling/disabling something I''m not? Thanks ahead of time for any help.

Share this post


Link to post
Share on other sites
What you need to do is to set the color to white before you render the floor. What is happening is the floor is taking the color of the last object you drew. OpenGL is a state machine and so the parameters don''t reset each time you draw a new frame. So you don''t need to enable lighting every frame if you don''t disable it, however you do need to set the position of the light if you allow movement of the viewpoint.

James

Share this post


Link to post
Share on other sites
thanks for the help! setting the color was exactly the problem I was having with the floor changing colors.

But I''m still stuck with why my gold object is changing colors by the color of the floor. For example, if i add a green floor below the object, the object becomes darker and is a greenish gold. I do set the color and material for each object now.

thanks ahead of time.

Share this post


Link to post
Share on other sites