Advertisement Jump to content


This topic is now archived and is closed to further replies.

Florian Nentwich

Spot lighting

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I create a spot-light correctly? I''ve gone through the first nine tutorials, and only the point-light was described. Does this topic appear in a later tutorial?

Share this post

Link to post
Share on other sites
I''m no expert in this OpenGL.. But how about if you just put your light inside of a tube, and enabled shadows? then you would have a spotlight effect.. =)

Kenneth Wilhelmsen
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder

Share this post

Link to post
Share on other sites
try looking up glLight in either the MSDN or online or in and opengl book ... creating spotlights are well documented

Share this post

Link to post
Share on other sites
Red Book, page 189

Basically, there are two functions to make spotlights using OpenGL.

First, define your light like a normal light.

Second, use the GL_SPOT_CUTOFF parameter in glLightf and specify an angle. This angle is the angle between the center of the spotlight and the beam. I hope you get what I mean by the angle, because it is hard to explain without a picture. 180 degrees is a normal light. 90 degrees would look kinda weird. I''m betting on 45 to 60 degrees. And you can use a really low value like 5 or something if you wanted to simulate a laser ().

The code looks something like this for the first statement
glLightf(GL_LIGHT#, GL_SPOT_CUTOFF, degrees);

Where # is the number of the light from 0 to 7, and degrees is the angle that I rambled about, from 0 to 90, or the special case of 180 degrees.

The second line of code is simply using GL_SPOT_DIRECTION and feeding it a vector to specify the direction the spotlight is facing.

Looks something like this

GLfloat vector[] = {x, y, z};
glLightfv(GL_LIGHT#, GL_SPOT_DIRECTION, vector);

# is a number from 0 to 7
vector is the location that the light points too
If you don''t know what x, y, and z are, I''ll hit you :D

I hope this helps.


Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!