Your confusion stems from the fact that you think you pass textures to sampler uniforms. This is not the case.
When you give a value to a sampler uniform, the value you are supposed to supply is the texture unit. Say you had a texture and bound it to GL_TEXTURE0
, then you would give the sampler uniform the value: 0
. Generally you treat samplers as integer uniforms, by the way, so the proper code would probably be: program.setUniformi (sampler2D, 0);
This tells GLSL that the sampler will use texture unit 0, the actual texture used will depend on whatever is bound to that texture unit.