[ Previous | Next | Contents | Glossary | Home | Search ]
OpenGL 1.1 for AIX: Reference Manual

glBindTexture Subroutine

Purpose

Binds a named texture to a texturing target.

Library

OpenGL C bindings library: libGL.a

C Syntax

void glBindTexture(GLenum target, GLuint texture)

Parameters

target Specifies the target to which the texture is bound. Must be either GL_TEXTURE_1D, GL_TEXTURE_2D, or GL_TEXTURE_3D_EXT (EXT_texture3D).
texture Specifies the name of a texture.

Description

The glBindTexture subroutine lets you create or use a named texture. Calling glBindTexture with target set to GL_TEXTURE_1D, GL_TEXTURE_2D, or GL_TEXTURE_3D_EXT 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 zero is reserved to represent the default texture for each texture target. Texture names and the corresponding texture contents are local to the shared display-list space (see glXCreateContext) of the current GL rendering context; two rendering contexts share texture names only if they also share display lists.

You can use glGenTextures 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 (1D), a texture first bound to GL_TEXTURE_2D becomes two-dimensional (2D), a texture first bound to GL_TEXTURE_3D_EXT becomes three-dimensional (3D). The state of a (1D) texture immediately after it is first bound is equivalent to the state of the default GL_TEXTURE_1D at GL initialization, and similarly for 2D and 3D 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 zero 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 rebound 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.

The glBindTexture subroutine is included in display lists.

Errors

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

GL_INVALID_OPERATION is generated if texture has a dimensionality which doesn't match that of target.

GL_INVALID_OPERATION is generated if glBindTexture is executed between the execution of glBegin and the corresponding execution of glEnd.

Associated Gets

glGet with argument GL_TEXTURE_1D_BINDING

glGet with argument GL_TEXTURE_2D_BINDING

glGet with argument GL_TEXTURE_3D_BINDING_EXT

Related Information

The glAreTexturesResident subroutine, glDeleteTextures subroutine, glGenTextures subroutine, glGet subroutine, glGetTexParameter subroutine, glIsTexture subroutine, glPrioritizeTextures subroutine, glTexImage1D subroutine, glTexImage2D subroutine, glTexImage3DEXT subroutine, glTexParameter subroutine.


[ Previous | Next | Contents | Glossary | Home | Search ]