Hi all
to implement lighting I have an uniform array of structures which is
uniform struct lightStruct{
int enabled;
vec2 attenuation;
vec3 color;
vec3 pos;
}light[NUM_LIGHTS];
(NUM_LIGHTS is eight)
And to get the locations i use this code:
u_lightEnabled_loc[0]=glGetUniformLocation(programName,"light[0].enabled");
u_lightPos_loc[0]=glGetUniformLocation(programName,"light[0].pos");
u_lightColor_loc[0]=glGetUniformLocation(programName,"light[0].color");
u_lightAttenuation_loc[0]=glGetUniformLocation(programName,"light[0].attenuation");
u_lightEnabled_loc[1]=glGetUniformLocation(programName,"light[1].enabled");
u_lightPos_loc[1]=glGetUniformLocation(programName,"light[1].pos");
u_lightColor_loc[1]=glGetUniformLocation(programName,"light[1].color"
u_lightAttenuation_loc[1]=glGetUniformLocation(programName,"light[1].attenuation");
....
The locations seem to be correct as they form a contiguous set of integers.
However, when I set for example the value of u_lightEnabled_loc[5] using glUniform1i(u_lightEnabled_loc[5],x), the "enabled" field of all lights is set to x. What am I doing wrong?
Thanks in advance.