I'm trying to understand uniform samplers and textures in GLSL. Right now, I understand basic uniforms, in that if I have
uniform float someFloat;
in my shader, I would write (pseudocode) such as
someFloatLoc = glGetUniformLocation(program, "someFloat")
glUniform1f(someFloatLoc, 3.14159)
to set the value of the uniform.
However, if I instead have
uniform shader1d t1;
uniform shader2d t2;
in my shader, what is the corresponding OpenGL function to set the texture? I would expect to find something like glUniformshader2d(uniform_loc, texture)
wherein texture
is an array specifying the texture, but so far my research leads me to a large number of functions, like glActiveTexture
, glGenTextures
, glBindTextures
, glTexImage2d
, and constants like GL_TEXTURE1
. But all I'm trying to do is assign an array specifying the texture to a specific shader uniform samplerXd foo
so I then can compute the output color based on fetchTexel(foo, texture_coord)
.
My question can be summarized as follows:
How can I mimic the functionality of glUniform1f
for a uniform float in a GLSL shader, but for a uniform sampler instead?