Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to ask which one of the


is better to use after I finished my texture rendering. Is there any difference performance-wise?

share|improve this question

These are two fundamentally different things.

glDisable (GL_TEXTURE_2D)

  • Disables 2D textures for the active Texture Unit in the fixed-function OpenGL pipeline.

  • In programmable OpenGL (GLSL or the older ARB VP/FP assembly languages), enabling or disabling GL_TEXTURE_2D is meaningless.

glBindTexture (GL_TEXTURE_2D,0)

  • Binds the "default" texture to the active Texture Image Unit.

  • For all intents and purposes, there is always a texture bound to a Texture Image Unit; 0 is just a special-case with an initially incomplete set of states, thus complicating validation (see below).

There is a little bit of validation overhead associated with binding any OpenGL resource (GLSL programs and FBOs tend to have the most complicated validation). In general, changing an object binding tends to be more expensive than changing one or two states associated with a bound object.

Therefore, unnecessarily changing the bound texture is inadvisable.

If your intention by binding 0 was simply to "disable" a texture, you would be better off setting a uniform value to communicate this intent to a shader. Uniforms are extremely cheap to set (assuming you do not do something stupid like query their location everytime you set them). Changing a uniform is orders of magnitude quicker than binding a different texture or even worse a different GLSL program.

If you are using fixed-function OpenGL:

  • Disabling GL_TEXTURE_2D is a better way of approaching this problem.
  • Changing bound objects should be done as little as possible.

If you are using programmable OpenGL:

  • Neither of these things make much sense.
  • Work your desired behavior into your shaders.
share|improve this answer
Thank you for your answer. I am using fixed-function OpenGL and Im trying to create simple library with functions for rendering 2D textures. – Alexander May 6 '14 at 21:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.