Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set the texture for by glUniform1i

Tags:

opengl

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** )?

like image 823
Yongwei Xing Avatar asked Mar 12 '12 04:03

Yongwei Xing


1 Answers

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

like image 154
Tim Avatar answered Oct 01 '22 16:10

Tim