View Full Version : Lighting
10-20-2005, 02:18 AM
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.
10-20-2005, 10:15 AM
hm...didn't help really :(
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:
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// 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
10-21-2005, 03:27 AM
omfg it works ^^ thx for your help
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.