tags:

views:

38

answers:

2

In OpenGL I have always understood that glEnable(GL_TEXTURE1D), glEnable(GL_TEXTURE2D) and/or glEnable(GL_TEXTURE3D) (and corresponding glDisable) is a per texture unit parameter.

Recently I tried to confirm this but have not found any clear documentation confirming either way regarding this question.

Put simply and in code, should I be doing this

glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
... bind etc ... 

glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
... bind etc ...

or this

glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE0);
... bind etc ...

glActiveTexture(GL_TEXTURE1);
.... bind etc ...

I was hoping to find some clarity.

+6  A: 

It's per texture unit.

From the GL1.5 specification, 3.8.15:

Each texture unit is enabled and bound to texture objects independently from the other texture units

Bahbar
+3  A: 

It is indeed per texture unit. The most recent documentation I found mentioning this explicitly was the Open GL specification 2.1 (2006 update) here

In section 3.8.16: Texture Application

It is probably mentioned somewhere in the new specifications but they were heavy re-organized. You can have a look at all the Open GL version specifications on the opengl org website (I wanted to post a link but I can't seem to post more than one).

SavageKai
Well, actually, it's not going to be in the latest core revisions because fixed-function was deprecated and then removed, and the Enable is controlling the fixed-function state. It does not have any effect on shaders.
Bahbar
That's good to know!
Montdidier
@Bahbar: Do you mean the GLSL shaders with their annotations can control the state of the texture units and samplers and thus there is no need for an explicit glEnable(GL_TEXTURE2D) for example?
Montdidier
@Montdidier: Exactly.
Bahbar