GL_COLOR_MATERIAL: how to disable?
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.
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?
If you want the default "lighting" restored, you should set the default values for those components.
Am I making sense?
With glLightfv(GL_LIGHT0, GL_AMBIENT,&lightAmbient); and glLightfv(GL_LIGHT0, GL_DIFFUSE,&lightDiffuse); of course, thanks.
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 :)
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 :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement