I noticed (the hard way, by trial and error) that uniform sampler variables need to have their values set before the activation of the shader program object, but uniform floats need to have their values set after the program activation.
This is quite illogical and looks like a bug, or at least an undocumented and strange constraint. Is this something that pertains only to Nvidia drivers, or is it common behavior?
location_texture = glGetUniformLocationARB(programObj, "texture");
location_time = glGetUniformLocationARB(programObj, "time");
glUniform1iARB(location_texture, textureID); // Set BEFORE activation
glUseProgramObjectARB(programObj);
glUniform1fARB(location_time, t); // Set AFTER activation
Then after the app starts press CRTL-SHIFT-F to grab a frame. Then open up the XML file and see what uniform values are being used on the render calls. (should look like this: http://glintercept.nutty.org/Demo03/gliInterceptLog.xml
-scroll down to the first render call and click on GLSL1)
I think there’s something in your code. It should work fine to set both the floats and the samplers after you use the program. That’s what I do, and it works fine, both on NVIDIA and ATI hardware.
Hello,
I’m sure that it’s a problem in your code, because in the Shader Desinger, all uniforms are inserted inmediatelly after the program object is binded, and the application works without problems on NV hardware.
Ah, that was the problem. I should set the uniform to a texture UNIT to which the texture ID is bound, not to the texture ID itself. The GLSL specification
is not at all clear on this, and I have seen others being confused over the same issue. Thanks!