my code looks like this:
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 20);
//set Position of the Light
In my opinion the light should stay stationary if the values in the gluLookAt-Function change. But the light only stays stationary if i perform a translation. If i perform a rotation with the gluLookAt-Function the light rotates too. It seems that the light rotates with the viewport. But with the glLightf*() command set after all model- and viewing transformations the light should’nt move.
Has anyone an explanation for this?
it gets rotated because it is set after the matrices hence it will be translated with those
to avoid I think you’d do
now do the other transforms
you likely would do the gluLookAt before lightfv so, to make sure that when moving the world around, the light would “stay” in the world where it was, not stay relative to camera
I did change my code as discribed above, but the behavior of the light did’nt change:
when i translate the viewport via gluLookAt() the light stays fix. But when the viewport is rotated via gluLookAt() the light position changes with this rotation. Well, at the moment i’m quiet clueless, so is there anyone who can explain this strange behavior of the light?
Your problem is that you didn’t put the spot direction after transformation and rotation in the modelview matrix.
Put glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION,…) where you set the light position and the light should stay stationary.
Putting the spot direction after transformation and rotation solved the problem…Thank you!