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 :
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 …
You seem to be activating your shader before you try to set a uniform value,
so that common mistake is not the cause of your problems.
In some Nvidia drivers, I have experienced that glUniform1f and
glUniform1i were broken, so I had to work around the problem by
using glUniform1fv and glUniform1iv instead, and pass the pointer to
a scalar value. That was quite some time ago, though, and it would
surprise me if then haven’t fixed it now. I did report it as a bug.
[QUOTE=thokra;1243478]That’s not a mistake - having a current (or active) program object is mandatory to be able to use glUniform*() functions.
[/QUOTE]
That was his point (although a fairly useless one, aka “the problem is NOT this”). The common mistake is doing it in the wrong order - which OP did not as StefanG noted.
When I compile my program I get the following warnings :
fishdisplay.c:300:3: warning: implicit declaration of function ‘glUniform1i’
fishdisplay.c:306:3: warning: implicit declaration of function ‘glUniform1f’
I thought that was not a problem because the glUniform functions was found when linking.