[Front] [Reference] [Imp. Guide] [Index]

glBindTexture
[Prev] [Next]

glBindTexture: bind a named texture to a texture target.

C Specification | Parameters | Description | Notes | Errors | Associated Gets | See Also

[Up] C Specification

void glBindTexture(
    GLenum	 target,
    GLuint	 texture)

[Up] Parameters

target
Specifies the target to which the texture is bound. Must be either GL_TEXTURE_1D or GL_TEXTURE_2D. Initially, both GL_TEXTURE_1D and GL_TEXTURE_2D are bound to texture 0.
texture
Specifies the name of a texture.

[Up] Description

glBindTexture binds the texture named texture to the specified target. If the name does not exist, it is created. target must be either GL_TEXTURE_1D or GL_TEXTURE_2D. When a texture is bound to a target, the previous binding for that target is broken.

Texture names are unsigned integers. The value 0 is reserved to represent the default texture for each texture target. glGenTextures may be used to generate a set of new texture names.

When a texture is first bound, it assumes the dimensionality of its target: A texture first bound to GL_TEXTURE_1D becomes one-dimensional and a texture first bound to GL_TEXTURE_2D becomes two-dimensional. The state of a one-dimensional texture immediately after it is first bound is equivalent to the state of the default GL_TEXTURE_1D at GL initialization, and similarly for two-dimensional textures.

While a texture is bound, GL operations on the target to which it is bound affect the bound texture, and queries of the target to which it is bound return state from 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. When a bound texture is deleted, the default texture is bound to that target.

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 glTexImage1D or glTexImage2D. For additional control over performance, use glPrioritizeTextures.

[Up] Notes

glBindTexture is available only if the GL version is 1.1 or greater.

[Up] Errors

[Up] Associated Gets

glGet with argument GL_TEXTURE_1D_BINDING
glGet with argument GL_TEXTURE_2D_BINDING

[Up] See Also

glAreTexturesResident,
glDeleteTextures,
glGenTextures,
glGet,
glGetTexParameter,
glIsTexture,
glPrioritizeTextures,
glTexImage1D,
glTexImage2D,
glTexParameter

[Prev] [Next]
Front Reference [Imp. Guide] Index