# light position

This topic is 3290 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

what is the difference between: glLightfv(GL_LIGHT0,GL_POSITION,pos); gluLookAt(...); and: gluLookAt(...); glLightfv(GL_LIGHT0,GL_POSITION,pos); i get significant difference but i didn't know why. any help please. i also need an article that explains this.

##### Share on other sites
The position of the light is transformed by the modelview matrix. In the first code, the modelview matrix does not contain the lookat matrix, while in the second, it does.

##### Share on other sites
Given the following sequence of calls, the light is specified in world coordinates (i.e. relative to the origin):
glLoadIdentity()glLightfv(GL_LIGHT0,GL_POSITION,pos)gluLookAt(...)

And the following specifies the light in viewer/eye coordinates (i.e. relative to the camera):
glLoadIdentity()gluLookAt(...)glLightfv(GL_LIGHT0,GL_POSITION,pos)

##### Share on other sites
which is first applied model matrix or view matrix

p = ModelMatrix * ViewMatrix * p

or

p = ViewMatrix * ModelMatrix * p

may this helps me in guessing what is happening.

##### Share on other sites
There is only one matrix, so the correct answer is p = ModelviewMatrix * p. What that matrix looks like depends entirely on how YOU make it in YOUR program.

##### Share on other sites
There is no "model matrix" and no "view matrix". In OpenGL you just have the ModelView matrix, which combines the model and the view matrix. The thing is that gluLookAt() changes this modelview matrix, while glLightfv() uses the modelview matrix. So the position of the light depends on the modelview matrix at the time of the call, but whether or not you have called gluLookAt() changes what that modelview matrix is.

##### Share on other sites
OpenGL Vertex pipeline:
Modelling : is the process of transforming objects from model coordinates
to world coordinates.

Viewing : is the process of transforming world coordinates to view coordinates.

which is applied first ?

MV = M * V
or
MV = V * M

##### Share on other sites
The modelview matrix is, under those specifications, constructed as MV = V * M.

##### Share on other sites
and from which side the multipication is done
P = M * V * P
or
P = P * M * V

???

Those Information are necessary in order to know the internal work of
Pipeline, so i can guess why the effect of light position differes ?