Jump to content
  • Advertisement
Sign in to follow this  
fabien

Change the type of a light

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

Hi all! Imagine I have one light. This light can be directional, a pointlight or a spotlight. Now imagine this light (let say GL_LIGHT0) can change type. Whenever it wants. Although switching between a directional and a spot works well, changing for a spotlight to anything else brings the light to be forever a spot. Why? The glLight(GL_SPOT_*) call is never being cleared. Do you know if glPush/PopAttrib(GL_LIGHT0) could help me? Thanks for your help!

Share this post


Link to post
Share on other sites
Advertisement
Hum.

I feel really bad. That was so easy.

To restore the initial settings of a light, just restore it.

float direction[3] = {0.0f, 0.0f, -1.0f};
glLightfv(GL_SPOT_DIRECTION, direction);
glLightf(GL_SPOT_EXPONENT, 0.0f);
glLightf(GL_SPOT_CUTOFF, 180.0f);

And the light is no more a spot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!