Archived

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

SpotLights OpenGL

This topic is 6388 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

glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, LightDirection); glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, 90); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0); glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0); Witch values to choose to get a "normal", spotlight? The distance between the light and the vertex is 15 units. All help is wellcommed! Show me your code! Gandalf the White Gandalf the White

Share this post


Link to post
Share on other sites
How to create a decent spotlight in OpenGL? All my objects turn dark. I´m sure about the direction but not so sure about GL_SPOT_EXPONENT and the attenuation params. I set the angle to 90 degree. Nothing happend. Darker then coffe.

Please help, OpenGL wizard out there!

Gandalf the White


Gandalf the White

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hopefully this''ll help. I''m still rather new to the OpenGL stuff myself. It''s a section of code I got from a tutorial, and seems to work fairly well. (Adds a little ambience and specular light for effect)

GLfloat ambientlight[] = {0.5f, 0.5f, 0.5f, 1.0f};
GLfloat specular[] = {1.0f, 1.0f, 1.0f, 1.0f};

//enable lighting
glEnable(GL_LIGHTING);

//Set up light 0
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientlight);

//the light is composed of just diffuse and specular components
glLightfv(GL_LIGHT0, GL_DIFFUSE, ambientlight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
glLightfv(GL_LIGHT0, GL_POSITION, lightposition);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotdir);

//set up spot effects
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 60.0f);

//make a shiny spot
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 100.0f);

//enable the light
glEnable(GL_LIGHT0);

Share this post


Link to post
Share on other sites