uniform float doesn't work
hi !
I need to pass two parameters to my fragment shader, but I never get the right variable's values. So I tried to change the uniform to const variables like this :
Code :
/*******************/
/* FRAGMENT SHADER */
/*******************/
uniform sampler2D fishTex;
//uniform float aspectRatio;
//uniform float fishRadius;
const float aspectRatio = 1.5;
const float fishRadius = 0.5204475309;
...
and the shader works perfectly. Now if i try to do the same things with uniform :
Code :
/*******************/
/* FRAGMENT SHADER */
/*******************/
uniform sampler2D fishTex;
uniform float aspectRatio;
uniform float fishRadius;
...
And send the three values like this :
Code :
glUseProgram(texProgram);
GLint texVar = glGetUniformLocation(texProgram, "fishTex");
printf("fishTex : %d\n", texVar);
glUniform1i(texVar, 0);
texVar = glGetUniformLocation(texProgram, "aspectRatio");
printf("aspectRatio : %d\n", texVar);
glUniform1f(texVar, 1.5);
texVar = glGetUniformLocation(texProgram, "fishRadius");
printf("fishRadius : %d\n", texVar);
glUniform1f(texVar, 0.5204475309f);
I get positive variable's identifier (with the printf) but the values inside the shader doesn't change. Maybe they stay to 0. I don't understand where is the problem. I have wrote another shader with three uniform sampler2D and it works ...