uniform array of structures

Hi all
to implement lighting I have an uniform array of structures which is

Code:

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:
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.

This could be a driver bug. Which platform are you using?





If it really is a driver bug, a simple workaround would be to drop the struct and use four plain arrays.

 I use a Sony Ericsson Satio (TI Omap 3430 with SGX530) , OS is Symbian. I’ll try out the simple array version, thanks Smile

3DGamer wrote:
Hi all
to implement lighting I have an uniform array of structures which is


this bothers me. POwerVR seems not to follow the lights exported from a 3ds MAx design. Is this a known limitation ? What was 3DGamer talking about with his struct ?

Thank you

The use of a struct in this case is purely to make the shader code a little cleaner and easier to read. It does not affect the functionality that is available in the shader.


This appears to be a bug on this particular device, but other devices with SGX cores and different drivers may not have the same issue.