when I draw my objects, the lighting move depending on the cameras position.
But I already update lights position once a frame after setting the camera modelview matrix.

but it begins to be strange when I see that :
If I use gluLookAt, using direction and position extracted from the “home made” camera matrix. then the lighting is okay (static)
If I directly use glLoadMatrix with the home made matrix, then the lighting is wrong.

When I do a glGetFloat and I get the gluLookAt generated modelview matrix, each factor of this matrix differe from less than 0.0001 in comparison with the “home made” matrix.

If you specify positions after you have the viewing matrix on the modelview stack then your lights should not be in eye space.

Loading inverse(transpose on afine) as you know is just because viewing matrices are the inverse of their model matrix counterparts and this is how model+view concatenation works.

If that was a problem you’d see the viewing matrix was obviously wrong.

Are you sure you specify the position etc. for the light? Make sure for spotlights that you also specify the orientation (just incase this is an issue). There’s an outside chance this is a bug with the driver trying to be optimal but not realizing that the loadmatrix has dirtied the matrix, but I doubt it you may simply have a bug in your other code path.

In fact the more I think about it the more likely a bug in your code seems.

gluLookAt isn’t magical, it just computes a viewing matrix based on the arguments and loads it (or multiplies it I forget which). You may want to try a multmatrix on an identity loaded matrix instead, just as a crazy test.

Make sure your own code is on the modelview matrix when you load the viewing transformation, if you had the wrong matrix and subsequently loaded concatenated matrices you’d never tell. Also try to use the pipeline’s multmatrix with the viewing matrix and subsequent model matrix operations. This will preserve the same viewing matrix on the modelview matrix stack that you used for the lights and any problems with the viewing matrix will manifest themselves in the vertex transformation, not just the lighting so any issues will instantly obvious.

with the correct modelviewmatrix in your code. the light_position is directly transformaed by the current modelviewmatrix so it should be the same in both cases (glLoadMatrix or glLoadIdentity and then glMultMatrix) if you apply this command with the same modelviewmatrix .