PDA

View Full Version : Problem with global light position



JasonBecker
10-10-2010, 10:51 AM
Hello,

I have problem with setting light position related to global coordinates system. What I do is :

gluLookAt()
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

// draw objects

And it look lights source is always related to current camera view. How can i solve this problem ?

Thanks

BionicBytes
10-10-2010, 02:19 PM
The position specified by gllightfv is always multiplied by the current modelview matrix. Perhaps you need an identity matrix loaded before setting your global light.

JasonBecker
10-11-2010, 12:44 AM
Will it help if I revert gluLookAt ?
I mean sth like :

glLoadIdentity;

// setting camera position
gluLookAt

glPushMatrix
// gluLookAt reverse transformatio to global coord ???
glLightfv(GL_LIGHT0, GL_POSITION ...
glPopMatrix

glBegin
..... // render objects

BionicBytes
10-11-2010, 05:47 AM
try doing it this way:

//Set up global scene lights....
glLoadIdentity;
glLightfv(GL_LIGHT0, GL_POSITION ...

// setting camera position
glLoadIdentity;
gluLookAt (.....)
glBegin
..... // render objects