glBindTexture

bind a named texture to a texturing target

Signature

glBindTexture( GLenum ( target ) , GLuint ( texture ) )-> void
glBindTexture( target , texture )
glBindTextures( first , count , textures )

Parameters

VariablesDescription
target
Specifies the target to which the texture is bound. Must be one of GL_TEXTURE_1D , GL_TEXTURE_2D , GL_TEXTURE_3D , GL_TEXTURE_1D_ARRAY , GL_TEXTURE_2D_ARRAY , GL_TEXTURE_RECTANGLE , GL_TEXTURE_CUBE_MAP , GL_TEXTURE_CUBE_MAP_ARRAY , GL_TEXTURE_BUFFER , GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY .
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_1D , GL_TEXTURE_2D , GL_TEXTURE_3D , GL_TEXTURE_1D_ARRAY , GL_TEXTURE_2D_ARRAY , GL_TEXTURE_RECTANGLE , GL_TEXTURE_CUBE_MAP , GL_TEXTURE_CUBE_MAP_ARRAY , GL_TEXTURE_BUFFER , GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY 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 object space of the current GL rendering context; two rendering contexts share texture names only if they explicitly enable sharing between contexts through the appropriate GL windows interfaces functions.
You must 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, a texture first bound to GL_TEXTURE_1D_ARRAY becomes one-dimensional array texture, a texture first bound to GL_TEXTURE_2D_ARRAY becomes two-dimensional array texture, a texture first bound to GL_TEXTURE_RECTANGLE becomes rectangle texture, a texture first bound to GL_TEXTURE_CUBE_MAP becomes a cube-mapped texture, a texture first bound to GL_TEXTURE_CUBE_MAP_ARRAY becomes a cube-mapped array texture, a texture first bound to GL_TEXTURE_BUFFER becomes a buffer texture, a texture first bound to GL_TEXTURE_2D_MULTISAMPLE becomes a two-dimensional multisampled texture, and a texture first bound to GL_TEXTURE_2D_MULTISAMPLE_ARRAY becomes a two-dimensional multisampled array 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 the other texture types.
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 glTexImage1D , glTexImage2D , glTexImage3D or another similar function.

Notes

The GL_TEXTURE_2D_MULTISAMPLE and GL_TEXTURE_2D_MULTISAMPLE_ARRAY targets are available only if the GL version is 3.2 or higher.

Errors

GL_INVALID_ENUM is generated if target is not one of the allowable values.
GL_INVALID_VALUE is generated if texture is not a name returned from a previous call to glGenTextures .
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_1D , GL_TEXTURE_BINDING_2D , GL_TEXTURE_BINDING_3D , GL_TEXTURE_BINDING_1D_ARRAY , GL_TEXTURE_BINDING_2D_ARRAY , GL_TEXTURE_BINDING_RECTANGLE , GL_TEXTURE_BINDING_BUFFER , GL_TEXTURE_BINDING_CUBE_MAP , GL_TEXTURE_BINDING_CUBE_MAP , GL_TEXTURE_BINDING_CUBE_MAP_ARRAY , GL_TEXTURE_BINDING_2D_MULTISAMPLE , or GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY .

Version Support

glBindTexture

See Also

Copyright

Copyright
1991-2006 Silicon Graphics, Inc. Copyright
2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see .

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
OpenGLContext OpenGLContext/texture.py Lines: 84, 96, 106, 247, 269, 299
OpenGLContext OpenGLContext/scenegraph/shaders.py Lines: 256
OpenGLContext tests/shadow_1.py Lines: 515, 562, 645
OpenGLContext tests/dek_texturesurf.py Lines: 53, 107
OpenGLContext tests/nehe6_compressed.py Lines: 32, 59
OpenGLContext tests/nehe8.py Lines: 94, 132, 140, 148
OpenGLContext tests/shadow_2.py Lines: 74, 117, 130
OpenGLContext tests/nehe6_convolve.py Lines: 102, 157
OpenGLContext tests/nehe7.py Lines: 99, 107, 115, 143
OpenGLContext tests/nehe6.py Lines: 51, 85
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 73, 86, 92, 196
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 70
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 146
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 35
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 38
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 40, 93, 116
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 74
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 71
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 192
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson44/glFont.py Lines: 48, 73
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson43/glFreeType.py Lines: 101, 128
{LGPL} PyUI2 renderers/openglGlut.py Lines: 207
{LGPL} PyUI2 renderers/openglBase.py Lines: 182, 220
{LGPL} PyUI2 renderers/openglPygame.py Lines: 154, 278, 311
{LGPL} PyUI2 system/openglgraphics.py Lines: 154, 224, 330, 363
{LGPL} VisionEgg VisionEgg/SphereMap.py Lines: 655, 795, 953, 1204
{LGPL} VisionEgg VisionEgg/Gratings.py Lines: 254, 320, 573, 644
{LGPL} VisionEgg VisionEgg/Textures.py Lines: 494, 499, 505, 511, 517, 523, 599, 788, 909, 1040, 1292, 1588
{LGPL} PyMT pymt/texture.py Lines: 17, 152, 314
{LGPL} PyMT pymt/graphx/statement.py Lines: 55, 270
{LGPL} PyMT pymt/graphx/paint.py Lines: 17, 78
{LGPL} Pyggel pyggel/data.py Lines: 143, 167
{LGPL} pygl2d pygl2d/image.py Lines: 70, 135
{GPL} Scocca scocca/graphics/opengl/texture.py Lines: 22
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/Visualisation/PhysicsGraph3D/Particles3D.py Lines: 412, 516, 580, 626
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 853, 901
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/PygameWrapper.py Lines: 189
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/Button.py Lines: 170, 256
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/TexPlane.py Lines: 94, 136
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/Label.py Lines: 145, 204
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Utils/Particles3D.py Lines: 153, 252, 315, 356
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 153, 159, 165, 202
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 101
{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/Button.py Lines: 174, 267
{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/Label.py Lines: 145, 204
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Button3D.py Lines: 134, 214
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/PygameWrapperPlane.py Lines: 145
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/TexPlane.py Lines: 137, 233
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Display3D.py Lines: 446, 469
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Button.py Lines: 102, 170
{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/MH/OpenGL/3dFolding.py Lines: 132, 188
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/Button.py Lines: 170, 256
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/Label.py Lines: 145, 204
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Button3D.py Lines: 134, 214
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/PygameWrapperPlane.py Lines: 145
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/TexPlane.py Lines: 137, 233
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Display3D.py Lines: 446, 469
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Button.py Lines: 102, 170
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/PygameWrapperPlane.py Lines: 72
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/TexPlane.py Lines: 54, 96
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 492, 520
{LGPL or GPL or MPL} Kamaelia Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Label.py Lines: 145, 204
Visvis core/line.py Lines: 64, 96
Visvis core/baseTexture.py Lines: 228, 341, 356
{GPL3} OpenGL-Programmable 05-shader.py Lines: 103
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 120
{GPL3} OpenGL-Programmable 03-array.py Lines: 35
{GPL3} OpenGL-Programmable 09-gles2.py Lines: 138
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 111
{GPL3} OpenGL-Programmable 10-gl3.2core.py Lines: 146
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 35
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 36
{GPL3} OpenGL-Programmable 01-direct.py Lines: 35
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 120