Unexpected behaviour with OpenGLTexture

Hello there,

I encountered something weird (for me). I made a small app where I want to pass an OpenGLTexture as a sampler2D-Uniform to my shaderProgram.

I'm doing this as follows in the renderOpenGL() function:

openGLTexture.bind();
GLint texID = openGLTexture.getTextureID();
texUniform->set( texID );

So when I use the identifier "texID" the texture is not passed to the shader. "texID" equals 1.

When I do it like this:


openGLTexture.bind(); 
texUniform->set( 0 );

it works.

 

Why is that so? Could someone enlighten me please?

A uniform value for a sampler refers to the texture unit and not the texture id. See http://stackoverflow.com/questions/9661878/set-the-texture-for-by-gluniform1i

thank you very much!