View Full Version : Bad lights - Why?

04-30-2001, 09:30 AM
I have built a 3D-Engine with Lightsources and I have a Problem: If I'm walking around, the lightsource follows me!!

GLfloat LightAmbient[]= { 0.7f, 0.7f, 0.7f, 0.2f };
GLfloat LightDiffuse[]= { 0.5f, 1.0f, 1.0f, 1.0f };
GLfloat LightPosition[]= { 0.0f, 0.0f, 3.0f, 1.0f };


glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);

04-30-2001, 10:09 AM
The position of the lightsource is transformed through the ModelView matrix stack. So if you want the lights to be fixed in the world, set up your light positions after your camera rotation.

04-30-2001, 10:34 AM
Thank you.
And how can I set the range of the lightsource?

05-01-2001, 09:27 AM
You can't. You have to turn it off manually when the object get too far away.

05-01-2001, 10:57 AM
That's not entirely correct. You can set attenuation factors for lights. This won't prevent the lighting calculations from taking place in the event that the light is beyond the range of being useful in the scene, so it is to your benifit to turn off negligible lights.