glBindTexture — bind a named texture to a texturing target

C Specification

void glBindTexture(GLenum target,
 GLuint texture);



Specifies the target to which the texture is bound. Must be GL_TEXTURE_2D.


Specifies the name of a texture.


glBindTexture lets you create or use a named texture. Calling glBindTexture with target set to GL_TEXTURE_2D, and texture set to the name of the new texture binds the texture name to the target. When a texture is bound to a target, the previous binding for that target is automatically broken.

Texture names are unsigned integers. The value 0 is reserved to represent the default texture for each texture target. Texture names and the corresponding texture contents are local to the shared texture-object space (see eglCreateContext) of the current GL rendering context.

You may use glGenTextures to generate a set of new texture names.

While a texture is bound, GL operations on the target to which it is bound affect the bound texture. If texture mapping of the dimensionality of the target to which a texture is bound is active, the bound texture is used. In effect, the texture targets become aliases for the textures currently bound to them, and the texture name 0 refers to the default textures that were bound to them at initialization.

A texture binding created with glBindTexture remains active until a different texture is bound to the same target, or until the bound texture is deleted with glDeleteTextures.

Once created, a named texture may be re-bound to the target of the matching dimensionality as often as needed. It is usually much faster to use glBindTexture to bind an existing named texture to one of the texture targets than it is to reload the texture image using glTexImage2D.


GL_INVALID_ENUM is generated if target is not one of the allowable values.

Associated Gets

glGet with argument GL_TEXTURE_BINDING_2D

See Also

eglCreateContext, glActiveTexture, glCompressedTexImage2D, glCopyTexImage2D, glDeleteTextures, glGenTextures, glGet, glTexImage2D, glTexParameter


Copyright © 2003-2004 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see