Hi,
Is there a way to know from a vertex/fragment shader which lights are on or off, and what is the state of OpenGL lighting?
Hi,
Is there a way to know from a vertex/fragment shader which lights are on or off, and what is the state of OpenGL lighting?
I guess you're looking for those :
Don't know about the enabled/disabled state of a lightsource, but it shouldn't be too hard to tell the shader from your app what lights are on.Code :struct gl_LightSourceParameters { vec4 ambient; vec4 diffuse; vec4 specular; vec4 position; vec4 halfVector; vec3 spotDirection; float spotExponent; float spotCutoff; float spotCosCutoff; float constantAttenuation; float linearAttenuation; float quadraticAttenuation; }; gl_LightSourceParameters gl_LightSource[gl_MaxLights];
What is the state of OpenGL lighting? Yes.Originally posted by AdrianPi:
Hi,
Is there a way to know from a vertex/fragment shader which lights are on or off, and what is the state of OpenGL lighting?
Which light is enabled? Not directly. You can declare your own:
And then load it with:Code :uniform bool myLightEnable[8];
-mr. billCode :int myLightLocation = glGetUniformLocationARB( programObj, "myLightEnable"); glUniform1fvARB( myLightLocation, 8, pFloats );
Or you can just set the intensity of disabled lights to zero.
Thanks MrBill, but how do I know the lighting state from glsl?
You just said "yes", but not "how"![]()
Maybe you didn't notice the rather large gl_LightSourceParameters struct that PanzerSchreck posted. Or the array of these structures that he also mentioned. Maybe you should take a look at these, seeing as how they encapsulate OpenGL's lighting state.
Ys I saw that Korval, but I'm talking about the global lighting state, the one we set with glEnable(GL_LIGHTING)![]()
Yes, I saw that, but I'm talking about the global lighting state, the one we set with glEnable(GL_LIGHTING)
Originally posted by AdrianPi:
Yes, I saw that, but I'm talking about the global lighting state, the one we set with glEnable(GL_LIGHTING)-mr. billCode :// There *ARE* much *faster* ways to do this! // For teaching purposes only.... GLfloat Floats[8]; GLfloat *pFloats = &Floats[0]; for (int i=0; i<8; i++) { Floats[i] = glIsEnabled( GL_LIGHT0+i ); } int myLightLocation = glGetUniformLocationARB( programObj, "myLightEnable"); glUniform1fvARB( myLightLocation, 8, pFloats );