Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should glEnable(GL_TEXTURE_2D) be applied per texture unit

Tags:

opengl

In OpenGL I have always understood that glEnable(GL_TEXTURE_1D), glEnable(GL_TEXTURE_2D) and/or glEnable(GL_TEXTURE_3D) (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.

like image 341
Montdidier Avatar asked Oct 28 '10 08:10

Montdidier


2 Answers

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).

like image 191
SavageKai Avatar answered Oct 13 '22 17:10

SavageKai


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

like image 8
Bahbar Avatar answered Oct 13 '22 19:10

Bahbar