I have a program in which I want the user to be able to change light and clear colors at run time. I have a class called COpenGLManager that takes care of everything with OpenGL. I has these member functions to change colors:
void COpenGLManager::SetBGColor(GLfloat r, GLfloat g, GLfloat b)
{
m_afClearColor[0] = r;
m_afClearColor[1] = g;
m_afClearColor[2] = b;
glClearColor(m_afClearColor[0], m_afClearColor[1], m_afClearColor[2], 1.0);
}void COpenGLManager::SetAmbient(GLfloat r, GLfloat g, GLfloat b)
{
m_afAmbientLight[0] = r;
m_afAmbientLight[1] = g;
m_afAmbientLight[2] = b;
glLightfv(GL_LIGHT0, GL_AMBIENT, m_afAmbientLight);
(And so on for diffuse and specular light)
For some reason, calling these functions won’t change the color. However, if I move the calls to glLight/glClearColor to the drawing function the colors are changes as they should. Does anyone have a clue to what might be wrong?