PDA

View Full Version : LIGHT position.



VasRoG
10-04-2005, 02:59 AM
I've got one light source in my scene. And i would like to move it to the new position. My code is following:

OnCreate

GLEnable(GL_LiGhtinG);
GLEnable(Gl_LiGht0);

OnButtonClick

GLPushMatrix;
GlTranslatef (-1.0,1.0,0.0);
E[0]:= Ex/(Nx - 1 );
E[1]:= -Ey/(Ny - 1 );
E[2]:= Ez/ maximum;
GLLiGhtfv(GL_LiGht0, GL_Position, @E);
GlPopMatrix;

But the light source is don't move. Errors?
Ye, E : array [0..2] of GLFloat; ;)

ZbuffeR
10-04-2005, 08:53 AM
You still did not fix your G key ? it is always capslocked ?

read the docs :
"GL_POSITION :
params contains four integer or floating-point values that specify the position of the light in homogeneous object coordinates."

You can basically think of the fourth parameter as a sort of switch : put 1.0 for a positional light source (what you need), and put 0.0 for a directional light (infinite light with parallel rays, like the sun seen from earth, etc).

VasRoG
10-04-2005, 09:54 AM
My "G" key becomes popular here. :) I hope it don't enrage somebody.
Thanks for your answer, ZbuffeR.