PDA

View Full Version : OpengGL Lights



guille
03-30-2001, 07:56 AM
Hi, first of all I am sorry for my English...
I have a simple light like this:
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv( GL_LIGHT0, GL_SPECULAR, LightSpecular);
glLightfv(GL_LIGHT0, GL_POSITION,LightPosition0);
glEnable(GL_LIGHT0);
glEnable( GL_LIGHTING );
and I am drawing some polygons that I can move using the mouse. In my drawing routine a do like this:
ClearGLScene();
glPushMatrix();
glTranslated(0,0,zoom);
glRotated(xrot, 1.0, 0.0, 0.0);
glRotated(yrot, 0.0, 1.0, 0.0);
glRotated(zrot, 0.0, 0.0, 1.0);
... Drawing the polygons ...
glPopMatrix();

I want the light fixed and the polygons moving... Is it something about pushing the matrix and then to disable the lighting?
Thank you all.

mango
03-30-2001, 01:29 PM
Well, what is the problem?
If you are setting the lights in your init code and do not touch them later should they be fixed. Your code also seems to move the polygons.

Why should you disable lighting?

guille
04-01-2001, 11:43 PM
Well, I'm a newbie and I really don't know if the light is fixed. I am drawing just 3 faces of a cube (like the thre planes X, Y, Z). I set the light in the begining, before any drawing. But then, when I move the faces with the mouse the light doesn't seem to be fixed. I am going to try to explain (I'm sorry for my English http://www.opengl.org/discussion_boards/ubb/wink.gif).
I draw the three faces as three polygons.
When I move them, just one seems to be reflecting the light (the Z plane).
[For each polygon I put its Normal]
If I rotate the faces and put one face (the Z plane) in the front (of my window) and start to spin it clock wise, this face reflects the light just sometimes. It is like if you put a mirror in front of you and start to spin it in clock wise. The mirror must reflect you all the time!. But the face only reflects the light at 12:00 o'clock position. That is why I am thinking that the light is moving.
Maybe I should try to use glLookAt instead of glRotate and glTranslate??
I really don't know. http://www.opengl.org/discussion_boards/ubb/frown.gif
Thankx for replying.

zed
04-02-2001, 12:46 AM
check out the faq (link first page on right) u should be position the lights after you've moved 'the camera'