What are the semantics of glBindMultiTexture and glEnableIndexed?
I have seen glBindMultiTexture used with glEnableIndexed where it seems to to something similar to e.g. glEnable(GL_TEXTURE_2D) though I am unsure if it is required or not and if it replaces glEnable(GL_TEXTURE_2D) or not, or should both be used? The DSA spec doesn’t seem to mention glEnableIndexed in the context of glBindMultiTextureEXT.
What is the correct usage?
// Init 1
glEnable(GL_TEXTURE_2D);
for(int n = 0; n < 4; ++n)
glEnableIndexed(GL_TEXTURE_2D, n);
// Init 2
for(int n = 0; n < 4; ++n)
glEnableIndexed(GL_TEXTURE_2D, n);
// Init 3
glEnable(GL_TEXTURE_2D);
// For each frame 1
for(int n = 0; n < 4; ++n)
glBindMultiTexture(GL_TEXTURE0 + n, GL_TEXTURE_2D, textureIds[n]);
// For each frame 2
for(int n = 0; n < 4; ++n)
{
glEnableIndexed(GL_TEXTURE_2D, n);
glBindMultiTexture(GL_TEXTURE0 + n, GL_TEXTURE_2D, textureIds[n]);
}
glEnableIndexed does not exist. glEnableIndexedEXT does however, as does
glEnablei(the core OpenGL 3.0 equivalent). I’ll assume you’re talking about them. Same goes for glBindMultiTextureEXT.Now that that bit of nomenclature is out of the way, it’s not entirely clear what you mean by “correct usage”.
If the intent of the “Init” code is to enable
GL_TEXTURE_2Dfor fixed-function use across the first four fixed-function texture units, then 1 and 2 will do that. 3 will only enable it for the current texture unit. Do note that this is only for fixed-function texture use.Which is where the other point comes in: generally, you do not simply enable a bunch of texture targets globally like that in an initialization routine. This would only make sense if everything you are rendering in the entire scene uses 4 2D textures in the first four texture units. Generally speaking, you enable and disable texture targets as needed for each object.
So I would say that having no enables in your initialization and enabling (and disabling) targets around your rendering calls is the “correct usage”.
Also, be advised that this is no different from directly using
glActiveTexturein this regard. So the fact that you’re using the DSA switch-less commands is irrelevant.