View Full Version : light position

09-17-2004, 02:46 AM
is the lighting positions in opengl world cordinates or camera space coords.. ie. do i need to do:

camera model view * light camera
then extract the position for the lights from here?

or can i just set position as if in world space?

09-17-2004, 03:16 AM
OpenGL treats the position and direction of a light source just as a geometric primitive.
When you specify the light position with a call to glLightfv(GL_LIGHT_POSITION,...), the light position is transformed by the data in the Modelview matrix.
If you want to update the light’s position, you must specify the light position again with the same call.
To achieve a fixed light position, set the light position before the viewing and modeling transformation

This would look something like this:

GLfloat light_ position[] = { 1.0, 1.0, 1.0, 1.0 };
glPushMatrix ();
glLightfv (GL_ LIGHT0, GL_ POSITION, position);
glPopMatrix ();

Originally posted by supagu:
or can i just set position as if in world space?Yes