brinck
08-10-2006, 08:17 AM
Hi,
I have a glsl program containing an array of uniform like this:
struct ControlPoint
{
vec4 position;
vec4 rotation;
vec4 some_data;
};
uniform ControlPoint control_points[30];On the cpu I have the exact same structure, and i was hoping that I would be able to do something like this
int base = glGetUniformLocationARB(m_program, "control_points[0].position");
glUniform4fvARB(base, 30 * 3, &m_control_points[0].position[0])to initialize the entire array of uniforms. This doesn't seem to work however.
Upon further investigation I discovered that
int index_0 = glGetUniformLocationARB(m_program, "control_points[0].position");
int index_1 = glGetUniformLocationARB(m_program, "control_points[0].rotation");
int index_2 = glGetUniformLocationARB(m_program, "control_points[0].some_data");returns index_0 = 0, index_1 = 2 and index_2 = 1, i.e. the glsl compiler doesn't respect the order of the members in my struct.
Is this to be expected? Is there any way to force the compiler to respect the order of the members in the struct?
/A.B.
I have a glsl program containing an array of uniform like this:
struct ControlPoint
{
vec4 position;
vec4 rotation;
vec4 some_data;
};
uniform ControlPoint control_points[30];On the cpu I have the exact same structure, and i was hoping that I would be able to do something like this
int base = glGetUniformLocationARB(m_program, "control_points[0].position");
glUniform4fvARB(base, 30 * 3, &m_control_points[0].position[0])to initialize the entire array of uniforms. This doesn't seem to work however.
Upon further investigation I discovered that
int index_0 = glGetUniformLocationARB(m_program, "control_points[0].position");
int index_1 = glGetUniformLocationARB(m_program, "control_points[0].rotation");
int index_2 = glGetUniformLocationARB(m_program, "control_points[0].some_data");returns index_0 = 0, index_1 = 2 and index_2 = 1, i.e. the glsl compiler doesn't respect the order of the members in my struct.
Is this to be expected? Is there any way to force the compiler to respect the order of the members in the struct?
/A.B.