bind a named texture to a texturing target
Signature
Parameters
Description
glBindTexture
lets you create or use a named texture. Calling
glBindTexture
with
target
set to
GL_TEXTURE_1D
,
GL_TEXTURE_2D
,
GL_TEXTURE_3D
or
GL_TEXTURE_CUBE_MAP
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 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_1D
becomes one-dimensional texture, a
texture first bound to
GL_TEXTURE_2D
becomes two-dimensional texture, a
texture first bound to
GL_TEXTURE_3D
becomes three-dimensional texture, and a
texture first bound to
GL_TEXTURE_CUBE_MAP
becomes a cube-mapped texture. 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-
and three-dimensional textures and 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. If texture mapping is active
on the target to which a texture is bound, 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 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
glTexImage1D
,
glTexImage2D
, or
glTexImage3D
.
For additional control over performance, use
glPrioritizeTextures
.
glBindTexture
is included in display lists.
Notes
glBindTexture
is available only if the GL version is 1.1 or greater.
GL_TEXTURE_CUBE_MAP
is available only if the GL version is 1.3 or greater.
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
.
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_BINDING_1D
glGet
with argument
GL_TEXTURE_BINDING_2D
glGet
with argument
GL_TEXTURE_BINDING_3D
See Also
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/
.
Sample Code References
The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.
glBindTexture
{LGPL} VisionEgg
VisionEgg/Textures.py
Lines: 494, 499, 505, 511, 517, 523, 599, 788, 909, 1040, 1292, 1588
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 830, 878
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/PygameWrapper.py
Lines: 189
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Label.py
Lines: 145, 204
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/TexPlane.py
Lines: 94, 136
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Button.py
Lines: 170, 256
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 831, 879
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/PygameWrapper.py
Lines: 189
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/Label.py
Lines: 145, 204
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/TexPlane.py
Lines: 94, 136
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/Button.py
Lines: 174, 267
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/PygameWrapperPlane.py
Lines: 72
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/TexPlane.py
Lines: 54, 96
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py
Lines: 492, 520
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/Button.py
Lines: 102, 170
{LGPL or GPL or MPL} Kamaelia
Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 830, 878