views:

72

answers:

2

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.

+1  A: 

It's more than likely static. This code is grabbing the position of the light, not the vector to the light from the vertex.

It's also static with respect to the current rendering pass. The vertex is at one location for the duration of the frame.

To retrieve information about lights in modern OpenGL, here is the documentation.

colithium
GetLight is deprecated.
Lela Dax
Hmm. My professor in my computer graphics class literally just mentioned this yesterday. And the documentation didn't mention it was deprecated (at least not on the page I linked to). I wish they'd make it more obvious...
colithium
It is deprecated in latest spec. It is static though, thanks for the answer.
Lela Dax
+2  A: 

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.

Matias Valdenegro