Hi i am very new at OpenGL programming and i’ve got a problem with lighting. I positioned the light source on a special position and it looks quite good. But when walking through the level it seems that the light doesn’t sty at the position relativly to the level ( i think because the level is turing around ^^).
Sry for my english i am from germany… maybe if there is anyone knowing what i mean please help me thx

If you stipple the light position before the viewing, then it will follow your view.
For a light to ‘stay’, you’ll have to call to glLightfv (GL_POSITION) after gluLookAt or the other functions for managing the view.

Hope that helps.

hm…didn’t help really :frowning:
i don’t use know where to place the call to glLightfv… maybe knowing that i followed the NeHe-Tutorials helps you to find a solution?!

If you post some code, I’ll might be able to help you, I think.

As I said, there are different kind of ways on managing light positions in GL. The 2 main are lights that follow the camera, and lights that are static in the world.

For static lights in the world, you must declare all the glLightfv after the camera transformations, so a bit like this:


glMatrixMode (GL_MODELVIEW);

// camera code: gluLookAt or any glRotate, glTranslate and so
gluLookAt (eye.x, eye.y, eye.z, aim.x, aim.y, aim.z, up.x, up.y, up.z);

// lighting code
glLightfv (GL_LIGHT0, GL_POSITION, light_pos);
// other glLightfv

// scene rendering code


// swap buffers

omfg it works ^^ thx for your help