Reseting light settings

Started by
1 comment, last by doc_zero 20 years, 11 months ago
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.
Advertisement
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);
glEnable(GL_LIGHT1);

/* render enlighted models here */

you would then call :
glLightfv(GL_LIGHT2, GL_SPECULAR, default_specular_color);
glLightfv(GL_LIGHT0, GL_DIFFUSE, default_diffuse_color);
glDisable(GL_LIGHT1);
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.

Thanks.

This topic is closed to new replies.

Advertisement