Jump to content
  • Advertisement
Sign in to follow this  
BTierens

GL_COLOR_MATERIAL: how to disable?

This topic is 5038 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

Hello, I call glEnable(GL_COLOR_MATERIAL); to render some coloured polygons. Then, I would like to disable it to render some textured polygons but glDisable(GL_COLOR_MATERIAL); doesn't work. The lighting is changed and glDisable(GL_COLOR_MATERIAL); doesn't reset it. How can I disable GL_COLOR_MATERIAL, so the lighting is the same as before calling glEnable(GL_COLOR_MATERIAL);? P.S. Even if you call glEnable(GL_COLOR_MATERIAL); and then imediatly glDisable(GL_COLOR_MATERIAL); without doing anything, lighting is changed.

Share this post


Link to post
Share on other sites
Advertisement
If you enable GL_COLOR_MATERIAL, the DIFFUSE and SPECULAR parts of the material, is set to corespond to the current glColor.
If you want the default "lighting" restored, you should set the default values for those components.
Am I making sense?

Share this post


Link to post
Share on other sites
With glLightfv(GL_LIGHT0, GL_AMBIENT,&lightAmbient); and glLightfv(GL_LIGHT0, GL_DIFFUSE,&lightDiffuse); of course, thanks.

Share this post


Link to post
Share on other sites
It's the ambient and diffuse parts of the material (and not the specular of course), so do like this:

float fAmbient[] = {0.2f, 0.2f, 0.2f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, fAmbient);

float fDiffuse[] = {0.8f, 0.8f, 0.8f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, fDiffuse);

That should work :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!