# Is glActiveTexture() still needed?

I'm using OpenGL 4.30 with JOGL (in Java). I'm playing with basic texturing, trying to learn how it's done.

The textbook I'm using has the following code:

gl.glActiveTexture(GL_TEXTURE0); // is this line necessary?
gl.glBindTexture(GL_TEXTURE_2D, textureID);
gl.glDrawArrays(GL_TRIANGLES, 0, 3);


This works well enough. But I find that if I comment out the first line, that it appears to have absolutely no effect on my program. So what is its point? Can the GPU only hold a limited number of textures at once, and I'm using #0 to hold the texture referred to by textureID? If I keep reusing the same constant GL_TEXTURE0 for all of my textures, does that mean that I'm slowing everything down? Or is this just to support legacy code, and I don't need to call this function at all? I'm very confused as to why this line is needed, and what it's doing.

That's because TEXTURE0 happens to be the initial value. It might have an effect if you had previously set a different value.
• Can you explain what you mean by "simultaneously"? I've found that so long as I call glBindTexture() before glDrawArrays(), and put those two things in a loop, that I draw a scene with many different textures just fine. But I'm new at this, and I'm likely making a stupid error or two. Oct 12, 2022 at 6:40