Jump to content
  • Advertisement


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


Reseting light settings

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

Hello, everyone! I have a quick question. If I have a scene with the light setup how can I reset all light settings? Because if I have light0 as a directional light and then I set it as some other type it does not always reset all the values, and I do not have the same picture as I would have by using the second setting directly. Is there some way to say reset them all and go on or the only way is set all the parameters of the light? Thanks a lot.

Share this post

Link to post
Share on other sites
In OpenGL, there is no ''reset'' option as the initial state is not queryiable (except if you query it before you change anything on it).

At best you could push a state with glPushAttrib(GL_LIGHTING_BIT) and call glPopAttrib later. But this works for all light settings and you have to take care of other glPushAttrib calls and moreover this is pretty slow.

Otherwise, to reset the light settings, you can :
- call glLight for every parameter you want to reset,
- or call the corresponding reset call for every parameter you have set up. For instance if you have called :

glLightfv(GL_LIGHT2, GL_SPECULAR, specular_color_2);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color_0);

/* render enlighted models here */

you would then call :
glLightfv(GL_LIGHT2, GL_SPECULAR, default_specular_color);
glLightfv(GL_LIGHT0, GL_DIFFUSE, default_diffuse_color);

Share this post

Link to post
Share on other sites
I will try to do that. Then I have some missunderstanding about how lihts are set up. If I have a scene with the lights in it, then I have a camera location.
I think that I should not call
glLightfv(GL_LIGHT2, GL_SPECULAR, specular_color_2);
glLightfv(GL_LIGHT2, GL_POSITION, light2_location);
each time I draw the scene?
But if I do not, then it looks like my camera transformation changes the position of the light.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!