Hi all,
I’ve been trying to program a simple example in OpenGL for two days now. I’m drawing a sphere and trying to light it from one side.
//Code example using GLUT
//before the main loop:
glClearColor(0.7f, 0.7f, 0.7f, 0.5f );
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
//main loop:
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
if(bLight)
glEnable(GL_LIGHT0);
else glDisable(GL_LIGHT0);
glLightf(GL_LIGHT0, GL_POSITION,(5.0f,-5.0f,-5.0f,0.0f));
glPushMatrix();
glTranslatef(0,0,-200.0f);
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glutSolidSphere(100,10,10);
glPopMatrix();
glutSwapBuffers();
}
Whatever I’m putting into the glLightf(…) arguments, the light will not change a bit. Can anyone please tell me why? Am I pushing/popping wrong? Am I supposed to load the identity matrix at some point?