Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL: Turn off multiple texture units

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?

like image 354
itun Avatar asked Apr 18 '11 15:04

itun


People also ask

What is glActiveTexture?

Description. glActiveTexture selects which texture unit subsequent texture state calls will affect. The number of texture units an implementation supports is implementation dependent, it must be at least 2.

How many textures can you load in OpenGL?

OpenGL 3. x defines the minimum number for the per-stage limit to be 16, so hardware cannot have fewer than 16 textures-per-stage.

How do textures work in OpenGL?

A texture is an OpenGL Object that contains one or more images that all have the same image format. A texture can be used in two ways: it can be the source of a texture access from a Shader, or it can be used as a render target.


2 Answers

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.

like image 167
ltjax Avatar answered Nov 15 '22 13:11

ltjax


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

like image 36
Bart Avatar answered Nov 15 '22 12:11

Bart