61

I have a question about how to set the texture by glUniform1i. I have seen code like below.

glActiveTexture(GL_TEXTURE0); 
glBindTexture(GL_TEXTURE_2D, texture0);
glUniform1i(_textureUniform, 0);
glActiveTexture(GL_TEXTURE1); 
glBindTexture(GL_TEXTURE_2D, texture1);
glUniform1i(_textureUniform, 1);

Does it mean, if I use the number i in the glUniform1i, then I have to use glActiveTexture(GL_TEXTURE **i** )?

vallentin
  • 23,478
  • 6
  • 59
  • 81
Yongwei Xing
  • 12,983
  • 24
  • 70
  • 90

1 Answers1

59

Yes, you are correct. The uniform value for a sampler refers to the texture unit, not the texture id.

Tim
  • 35,413
  • 11
  • 95
  • 121