Static Light Source - What Am I Doing Wrong?

I seem to be still struggling with some basics.

I’m trying to create a scene where the camera is static, the light source is static, and the model rotates slowly, like a car revolving on a showroom turntable. Thus, no matter which side is currently facing the camera, some light should fall on it.

I can get everything working properly, except the light. Here’s how I create the scene’s co-ordinate space:

glFrustum(-0.2, +0.2, -0.16, +0.16, 0.1, 24.0);

This is what I do each frame update:


// Ensure everything starts from scratch.

// Position the camera.
gluLookAt(0.0, 0.0, 12.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

// Attempt to position the fixed light source.	

// Rotate the scene for drawing the model.
glRotated(dAngle, 0.0, 1.0, 0.0);


Here’s how I set the light position:

float fLightData[4];
fLightData[0] = -5.0f ;
fLightData[1] = 2.0f ;
fLightData[2] = 5.0f ;
fLightData[3] = 1.0f ;
glLightfv(GL_LIGHT0, GL_POSITION, fLightData);

It seems very simple, but despite trying various places to position the light source, I can’t get it right. If I put it after the glRotate, the light remains fixed on the same spot on the same side of the model - it rotates exactly with the model, which makes perfect since since the rotated scene affects where it is placed. So that seems the wrong place to do it - I need it independent of the rotation.

I’ve tried putting it both before and after the gluLookAt call, but in both cases the lighting is odd. It starts out in the right place, but as the model rotates, so apparently does the light; by the time the back face of the model is facing the camera, there is no light whatsoever. When it gets to about 3/4 of a full circle, the light appears to the right instead of the left, and appears to move across the face as it completes its circle.

It was my understanding that following glLoadIdentity, the light’s position should be in absolute co-ords. Thus, the position should never change even though I later rotate the scene to draw the model in the correct orientation.