PDA

View Full Version : gl_LightSource[0].position.xyz in modern OpenGL



tobindax
09-16-2010, 09:12 PM
I'm a beginner. I noticed in old code


// Calculate the light position for this vertex
vec3 vertex_light_position = gl_LightSource[0].position.xyz;
I assume that's dynamically changing and hence can't test it with simply a static vec3.

How do I go with replacing the above in modern OpenGL? An example would be greatly appreciated.

BionicBytes
09-17-2010, 11:06 AM
You need to supply your own uniforms instead of relying upon built-in ones. Exactly what you need depends upon your own requirement - anything goes!
The advantage of your own system is that lighting calculations can be in world space or lightspace - ie before multiplying with the modelview matrix