1991-2006 Silicon Graphics, Inc.

glBindTexture

3G

glBindTexture

bind a named texture to a texturing target

# C Specification

                    void glBindTexture
                    GLenum target
                    GLuint texture

## Parameters

`target`

- Specifies the target of the active texture unit to which the texture is bound. Must be either `GL_TEXTURE_2D` or `GL_TEXTURE_CUBE_MAP`.

`texture`

- Specifies the name of a texture.

## Description

`glBindTexture` lets you create or use a named texture. Calling `glBindTexture` with `target` set to `GL_TEXTURE_2D` or `GL_TEXTURE_CUBE_MAP` and `texture` set to the name of the new texture binds the texture name to the target of the current active texture unit. 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 object space of the current GL rendering context.

You may use

glGenTextures

to generate a set of new texture names.

When a texture is first bound, it assumes the specified target: A texture first bound to `GL_TEXTURE_2D` becomes a two-dimensional texture and a texture first bound to `GL_TEXTURE_CUBE_MAP` becomes a cube-mapped texture. The state of a two-dimensional texture immediately after it is first bound is equivalent to the state of the default `GL_TEXTURE_2D` at GL initialization, and similarly for cube-mapped 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. 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 re-bound to its same original target 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

.

## Errors

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

`GL_INVALID_OPERATION` is generated if `texture` was previously created with a target that doesn't match that of `target`.

## Associated Gets

glGet

with argument `GL_TEXTURE_BINDING_2D` or `GL_TEXTURE_BINDING_CUBE_MAP`

## See Also

glDeleteTextures

,

glGenTextures

,

glGet

,

glGetTexParameter

,

glIsTexture

,

glTexImage2D

,

glTexParameter

## Copyright

Copyright 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.