I’m trying to put a spotlight and a sphere on screen so that the latter rotates independently while the former’s focus stays on the same area of the sphere’s surface. In theory, this should look like the sphere isn’t even moving, but it isn’t working out that way. There’s obviously light coming from somewhere, but it seems like the source was rotating and moving randomly. I’m using the same variable for incrementing all angles, so the same phases repeat every 360 degrees, but I can’t think of a reason for this undefined light trajectory.
I tried putting a cone at the same place where the light source is supposed to be, and it does stay motionless exactly like it’s supposed to. Yet the light still moves, gradually shifting between lighting the whole sphere and showing only ambient light. The only thing I’m certain of is that the light source is not following the sphere’s rotation in any way; lighting in the same areas changes. Here are some of the key areas of my code; I got exactly the same results without providing a direction for the spotlight, so that’s the version I’m using here:
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glTranslatef(0.8, 0.8, -2.0);
glTranslatef(-0.4, -0.4, -5.0);
glRotatef(turn, 0.2, 0.5, -0.3);
// “turn” grows by 2 every 50 ms.
glLightfv(FSource, GL_POSITION, @FLocation);
// FLocation: [0, 0, 0, 1.0]
glLightfv(FSource, GL_DIFFUSE, @FDiffuse);
glLightfv(FSource, GL_SPECULAR, @FSpecular);