PDA

View Full Version : Lightning (enable/disable)



ei05tbe
07-11-2010, 12:33 PM
I am creating a number of lights. If I go to the "else" block, and wont no light what so ever. Is it enough to do

glDisable(GL_LIGHTING)

or do I a have to do


74 for(unsigned int i = 0; i < lights.size(); i++){
75 glDisable(GL_LIGHT0+i);
76 }

for each light also?

61 void State::apply(){
62
63 std::vector<Light*> lights = m_lightState.getLights();
64 if(m_lightState.isLight()){
65 for(unsigned int i = 0; i < lights.size(); i++){
66 if(lights[i]->isOn()){
67 glEnable(GL_LIGHT0+i);
68 } else {
69 glDisable(GL_LIGHT+i);
70 }
71 }
72 glEnable(GL_LIGHTING);
73 } else {
74 for(unsigned int i = 0; i < lights.size(); i++){
75 glDisable(GL_LIGHT0+i);
76 }
77 glDisable(GL_LIGHTING);
78 }

pjcozzi
07-11-2010, 02:40 PM
You can just do glDisable(GL_LIGHTING). Disabling individual lights is useful if you want to leave lighting and some other lights enabled.

Regards,
Patrick