OpenGL: Turn off multiple texture units
Asked Answered
L

2

5

How to turn off multiple texture units because they influence to other render parts. I activate my them:

        glActiveTexture(GL_TEXTURE0 + index);
        glBindTexture(GL_TEXTURE_2D,
               ((MaterialSampler2D)specular).texture.getTOB());
        shader.setTexture2(index);

Is there something like glDeactivateTexture?

Legg answered 18/4, 2011 at 15:48 Comment(0)
D
11

glActiveTexture does not activate texture-units. It merely selects which texture-unit you're currently modifying (yes, OpenGL's object state managing is horrible). You activate textures with glEnable(<texture-target>) and glDisable(<texture-target>). In your case, the target would be GL_TEXTURE_2D.

So to answer your question: Select the texture-unit i by using glActiveTexture(GL_TEXTURE0+i) and then disable it with glDisable(GL_TEXTURE_2D).

Note that all this is redundant with shaders - you can just not access the values there.

Duckworth answered 18/4, 2011 at 16:2 Comment(2)
I use shader and I don`t need to use glEnable/glDisable(GL_TEXTURE_2D), do I? And I use this, it does not help me.Legg
Exactly, except for some dodgy drivers that are buggy (and I think there was a bug that affected this issue on ATI drivers at one time)Duckworth
S
1

You mean something like glDisable? http://www.opengl.org/sdk/docs/man/xhtml/glEnable.xml

Slipper answered 18/4, 2011 at 15:52 Comment(2)
What argument value do you think help me?Legg
from the top of my head something like glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); Not sure if this is what you intend to do?Slipper

© 2022 - 2024 — McMap. All rights reserved.