PDA

View Full Version : problems on setting uniform array



Flying_sands
10-20-2005, 06:14 AM
in shader:
uniform vec3 BrickColor[2], MortarColor;
uniform vec2 BrickSize;
uniform vec2 BrickPct;

uniform mat3 myMat;

in order to set these uniform, app do like this:
float fv[6] =
{
1.0, 0.3, 0.2,
0.5, 0.4, 0.6
};
float fm[9] =
{
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
};

glUniformMatrix3fvARB(glGetUniformLocationARB(bric kProg, "myMat"), 1, GL_FALSE, fm);
glUniform3fvARB(glGetUniformLocationARB(brickProg, "BrickColor"), 2, fv);

the result is:
BrickColor[0] = 1.0, 0.3, 0.2
BrickColor[1] = 0.5, 0.4, 0.6
***myMat = 0.5, 0.4, 0.6,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
It seems that only 1 vec3 is allocated to the BrickColor array other than 2 vec3 while linking shader. So brickColor[1] and mat[0] share the memory, and the first column is writen by BrickColor[1] in this example.
Is this a bug?

sqrt[-1]
10-20-2005, 11:29 PM
How are you getting the uniform values back? (judging from the previous post you may be doing it incorrectly).

Flying_sands
10-21-2005, 12:07 AM
I test the value in shader, and then I know the value is error. But according to glsl reference, uniform array is permissible.

Flying_sands
10-21-2005, 01:32 AM
I have solved the problem after install the latest driver. My graphics card is NVidia6200, and the latest driver for it is 81.85, which is released today. Even 81.84 still contains bug.