Sign in to follow this  

Change the type of a light

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this