Search code examples
openglopengl-3

gl_LightSource[0].position.xyz in modern OpenGL


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.


Solution

  • The gl_LightSource is just an uniform array, for modern code you can just pass a uniform array of structures that contains your light data.