View Full Version : light: Lighting moves with camera

11-25-2002, 12:41 AM
In my scene the light keeps moving with the camera. I don't really want this (rather useless really) and I'd like my lighting to be on a fixed position in the scene. How can I accomplish this?

I set the light properties in the init of the scene and use GLUlookat to set my camera view.

11-25-2002, 12:48 AM
You have to set the light position after you have set the viewpoint transform.

11-25-2002, 01:04 AM
Originally posted by Bob:
You have to set the light position after you have set the viewpoint transform.


I called glLightFv after the glulookat now in the render function and it seems to work http://www.opengl.org/discussion_boards/ubb/smile.gif
But what I'm wondering about is WHY it works... isn't the light position affected by the rotation of the axis system?

11-25-2002, 01:13 AM
Yes, the light position is transformed by the modelview matrix.

11-25-2002, 03:08 AM
i believe all matrix operations happen in the reverse order that you specify, or something like that...

glRotatef(90, 1, 0, 0);
glTranslatef(10, 0, 0);

i think the translate will get matrixed (is this a word?!?) in first, then the call to rotate. i'm kinda sketchy on the details but i know i've seen this discussed here before.


[This message has been edited by jebus (edited 11-25-2002).]

11-25-2002, 03:22 AM
I'm 99.9% sure it works now... I had a bit of a blurry moment so I thought that the light SHOULD be affected by the glulookat in another way (monday, morning, hangover, you know the effects).