1

I'm currently learning some OpenGL theory. Now I got some questions of which I cant find an answer.

Here is one of my question: Lets assume, that I bind a GL_TEXTURE_2D to unit GL_TEXTURE0 like this:

GL.glBindTexture(GL.GL_TEXTURE_2D, myTexture1_ID);

Now I'm going to bind another one, but this time it's a GL_TEXTURE_1D.

GL.glBindTexture(GL.GL_TEXTURE_1D, myTexture2_ID);

What happens to the first binding call? Does it unbind, because of the same texture unit or does it stay, because of the different texture target?

Thanks!

bitQUAKE
  • 363
  • 1
  • 6
  • 18
  • I recommend using `glBindTextures` instead. Lets you bind all the textures at once, clear the unneeded bindings, and avoids specifying texture targets explicitly after creation. – Yakov Galka Apr 28 '17 at 09:06

1 Answers1

1

The texture binding to the target GL_TEXTURE_2D is left untouched as long as you are not rebinding another texture to the same target.

You can even bind multiple textures, each to a different "texture unit" by calling

glActiveTexture(GL_TEXTURE0 + i)

before binding a new texture.

Danny Raufeisen
  • 494
  • 5
  • 15
  • So I could bind a 1D, 2D and 3D texture to each unit from 0 to n at the same time, theoretically? – bitQUAKE Apr 28 '17 at 08:11
  • 1
    @bitQUAKE: Yes you can bind them at the same time, but not use them at the same time. There's a precedence between texture targets on a given texture unit and only the texture target with the highest precedence is being actively used. – datenwolf Apr 28 '17 at 08:18
  • Also very comprehensively explained by this user: http://stackoverflow.com/a/8887844/5790859 especially the part under "Active Texture" – Danny Raufeisen Apr 28 '17 at 08:26