   Lighting, or the Lack there of...
  Hi, I''m still working on a 3D modeling program, and it''s time for lighting. The Lighting shows up, but when i move the camera, it is as if the light doesn''t move. You can drag the corners of the shape in my program, and when you do, the shading across the shape does change, but even though I''ve got the position set to {0,0,-2}, so that it is 2 units behind the camera, it doesn''t Stay Behind the Camera.I''m using normals, and i''ve drawn them to make sure they are correct, so that isn''t the problem.Any Ideas? 
  Are you (re)setting the light every time you transform your scene? If not, ... you should :D First transform the viewport, then place your light (again) on the desired coordinates. Repeat it for every frame you draw ;  ok, So Like this?//DeclaredLightOnePosition[] = {0.0f, 0.0f, -2.0f};//Perform Transformation and RotationCamera.position();//Enable and Re-Set the LightingglEnable(GL_LIGHTING);glLight(GL_LIGHT1, GL_POSITION, LightOnePosition );//Draw Objects to be lightedDraw3DObjects();//Disable LightingglDisable(GL_LIGHTING);;  What''s inside your camera.position code?When relative to this code are you setting the modelview and projection matrices?And is there a reason you''re enabling and disabling lighting every frame?I enable lighting in the initialize function.In the render function, I set the projection matrix using gluPerspective, then LoadIdentity the modelview matrix and call glTranslate and glRotate.  Then I just position the light like I''m positioning a polygon and it gets transformed by the current matrix just like a polygon.   Love means nothing to a tennis playerMy nothing-to-write-home-about OpenGL webpage. (please pardon the popups!);  Camera.Position(); just sets the rotation and transformation of the camera incase i've changed the POV with the mouse.Before that code, I setup the ViewPort, MatrixMode, then LoadIdentity, then gluPerspectiveYes, I have to disable lighting after I've drawn the 3d stuff, because in my program there are three other views (2d) which do NOT need lighting.There are some pictures to show you what it IS doing here.What Sets the ModelView Matrix?   [edited by - manoc396 on February 16, 2004 1:48:09 PM] [edited by - manoc396 on February 16, 2004 1:55:49 PM];  There was a chap with similar problems not so long ago, hang on I''ll have a look for it; ahh, here it is, hope that helps.   --Cheers, ;  Hey, What if i haven't been calling glMatrixMode(GL_MODELVIEW);?What i've been doing is this://///////////////////////////////START CODEglViewport (mywidth/2,0,mywidth/2,myheight/2);glMatrixMode (GL_PROJECTION);glLoadIdentity ();gluPerspective( 45.0, (GLfloat)(mywidth/2)/(GLfloat)(myheight/2), 0.1f, 500.0 ); cam.position();//translate and rotate the cameraglEnable(GL_LIGHTING);glLightfv(GL_LIGHT1, GL_POSITION, LightOnePosition);glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, LightOneDirection);glEnable(GL_TEXTURE_2D);glColor3f(1.0f,1.0f,1.0f);drawshape3d();//this function includes Rotation and Transformation. glDisable(GL_LIGHTING);/////////////////////////END CODEis the rotation and translation in the DrawShapes3d() throwing everything off?I set the SpotLight Cut off and Direction, but no changes.See Anything in my Code?Also, i don't use PushMatrix() or PopMatrix() anywhere.. does that affect anything? [edited by - manoc396 on February 16, 2004 9:54:41 PM];  gluPerspective( 45.0, (GLfloat)(mywidth/2)/(GLfloat)(myheight/2), 0.1f, 500.0 ); after that line put in glMatrixMode(GL_MODELVIEW), lighting isn''t affected by the projection matrix ;  Ok, Thanks for your help. I finally found a kind of temporary soloution. Thanks again. ;  off topic, znear clipping plane should never be less then 1.0f 