I’m currently working with fragment shaders, and I was wondering how I could bind a texture to a uniform while the context’s bound texture is not this specific texture. For instance, my code for bounding the texture to the texture unit is :
glUniform1i(uniform, textures.get(name)); glActiveTexture(GL_TEXTURE0 + textures.get(name)); glBindTexture(GL_TEXTURE_2D, tex.texture.get(0));
Except that since the active texture is
GL_TEXTURE0 + textures.get(name), if i then call
glBindTexture() again, the newly bound texture is set as the uniform.
Do I have to then “move” the active texture to an unused texture unit index if I want to use
glBindTexture() again without it influencing the sampler2D ? or is there a cleaner way to do this (such as binding while not setting as a texture unit).