Spot lighting

Started by
4 comments, last by Florian Nentwich 22 years, 9 months ago
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?
Advertisement
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
try looking up glLight in either the MSDN or online or in and opengl book ... creating spotlights are well documented
Look in the OpenGL Redbook:
OpenGL Redbook

Try looking for GL_CUTOFF or something like that.

Scott


Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
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.

-Blackstream

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

-The Mad Hacker

Blackstream''s Webpage
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Thanks for your replies!

This topic is closed to new replies.

Advertisement