Ok!
I don’t make any differents between settings the “int” and “float” variables.
So, in the program this:
glUniform1fARB(glGetUniformLocationARB(gv_Shader_Test, "MY_FLOAT_VAR"), 10.0);
glUniform1iARB(glGetUniformLocationARB(gv_Shader_Test, "MY_INT_VAR"), 25);
In the shader it seems like this:
uniform float MY_FLOAT_VAR;
uniform int MY_INT_VAR;
void main(void)
{
vec3 color = vec3(1.0, 0.5, 0.25);
gl_FragColor = vec4(color, 1.0);
}
Also I have a script(#1) in my program:
char *s = (char*)malloc(255);
int l = 0;
int i = 0;
for(i = 0; i < 5; i++)
{
glGetActiveUniformName(gv_Shader_Test, i, 255, &l, s);
if(s != NULL)
{
printf("
l = %i, s = \"%s\"", l, s);
}
}
When I don’t use the variables in the shader, the script #1 returns:
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
Then I apply the changes to the fragment-shader:
void main(void)
{
vec3 color = vec3(1.0, 0.5, 0.25);
color /= MY_INT_VAR;
gl_FragColor = vec4(color, 1.0);
}
The script #1 returns:
l = 10, s = "MY_INT_VAR"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
That is ok! When I’m setting different values to MY_INT_VAR, I’m getting different colors.
Then I apply another changes to the fragment-shader:
void main(void)
{
vec3 color = vec3(1.0, 0.5, 0.25);
color /= MY_FLOAT_VAR;
gl_FragColor = vec4(color, 1.0);
}
So, I have:
l = 12, s = "MY_FLOAT_VAR"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
l = 37, s = "gl_ModelViewProjectionMatrixTranspose"
But in the shader MY_FLOAT_VAR is always zero. So, I’m setting different values to MY_FLOAT_VAR, but getting only white color.