PDA

View Full Version : Spotlight troubles



dpgraves
02-22-2002, 08:41 AM
I am having trouble getting a spotlight to work in my code. I am trying to get the spotlight to point in the positive x direction.

GLfloat dir = {1.0,0.0,0.0};

I believe that's the desired array I want. I call glLightfv with GL_SPOT_DIRECTION and then I make the call to specify the exponent. But whenever I call SPOT_CUTOFF with any valid angle I end up getting no light at all. I want this spotlight to be the only light in the scene for now so that I can see what it looks like. I was told that due to vertex lighting any polygons whose vertices are all outside the radius of the spotlight will cause the whole poly to be black. But the spotlight is shining on polygons that should fit entirely within the spotlight. There's something I'm not understanding. Thanks for any help.

DFrey
02-22-2002, 09:35 AM
If you do a search on either this forum or the advanced forum (I can't remember which one), you should be able to find a simple example program I posted that demonstrate how to use spotlights. The program used a spotlight and rotated it around a sphere while keeping it pointed at the sphere.

I found it: http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/004796.html

[This message has been edited by DFrey (edited 02-22-2002).]

dpgraves
02-22-2002, 09:45 PM
Thanks for the help. I fixed the problem. I realized that calls to position the light, set its direction, and to draw it needed to be in my draw function. Now I have a rotating spotlight in my scene, yaaaay :-D Kinda nifty effect.