GLBINDTEXTURE(3G)
π GLBINDTEXTURE β it's giving texture binding, bestie
okay so real talk, this is the 3G girlies' manual page for glBindTexture, and it's honestly one of the most main-character functions in all of OpenGL. Let's get into it β¨
πΈ NAME
glBindTexture β bind a named texture to a texturing target
π C SPECIFICATION
void glBindTexture(GLenum target, GLuint texture);
literally the whole signature. no notes. π
β¨ PARAMETERS
targetβ tells GL where you're binding the texture. Has to 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_MULTISAMPLEorGL_TEXTURE_2D_MULTISAMPLE_ARRAY. pick one, queen π«Άtextureβ the name of a texture. yes, just the name β not the whole texture, the name. it's a whole thing.
π₯ DESCRIPTION
so glBindTexture lets you create or use a named texture. π¦
when you call 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, it binds that texture name to that target. and the moment a texture is bound to a target, the previous binding for that target is automatically broken β like, no ceremony, it's just over π
okay now the lore:
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 β and two rendering contexts only share texture names if they explicitly enable sharing between contexts through the appropriate GL windows interfaces functions. iykyk. π
you must use glGenTextures() to generate a set of new texture names. no DIY names, bestie, that's not the vibe.
When a texture is first bound, it assumes the specified target. this is genuinely the most iconic part, so buckle up:
- a texture first bound to
GL_TEXTURE_1Dbecomes one-dimensional texture - a texture first bound to
GL_TEXTURE_2Dbecomes two-dimensional texture - a texture first bound to
GL_TEXTURE_3Dbecomes three-dimensional texture - a texture first bound to
GL_TEXTURE_1D_ARRAYbecomes one-dimensional array texture - a texture first bound to
GL_TEXTURE_2D_ARRAYbecomes two-dimensional array texture - a texture first bound to
GL_TEXTURE_RECTANGLEbecomes rectangle texture - a texture first bound to
GL_TEXTURE_CUBE_MAPbecomes a cube-mapped texture - a texture first bound to
GL_TEXTURE_CUBE_MAP_ARRAYbecomes a cube-mapped array texture - a texture first bound to
GL_TEXTURE_BUFFERbecomes a buffer texture - a texture first bound to
GL_TEXTURE_2D_MULTISAMPLEbecomes a two-dimensional multisampled texture - a texture first bound to
GL_TEXTURE_2D_MULTISAMPLE_ARRAYbecomes a two-dimensional multisampled array texture
periodt. π
and listen β 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. so it's a clean slate, it's a fresh start, it's a new semester. π§
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. it's giving identity theft but make it legal. π
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(). those are the only two ways out, fr fr.
and once created, a named texture may be re-bound to its same original target as often as needed. plus β and this is the tip that ate β 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. so stop reloading, start rebinding, your framerate will thank you π₯
π 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. no 3.2, no multisample, that's the rule π
π ERRORS
GL_INVALID_ENUMis generated iftargetis not one of the allowable values. pick a real target bestie.GL_INVALID_VALUEis generated iftextureis not a name returned from a previous call toglGenTextures(). like I said βglGenTextures(), always.GL_INVALID_OPERATIONis generated iftexturewas previously created with a target that doesn't match that oftarget. the target said what it said π
π 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.
yes, GL_TEXTURE_BINDING_CUBE_MAP really is listed twice up there. that's the page, not me. I don't make the rules, I just vibe with them π«Ά
π VERSION SUPPORT
the whole grid, but make it a list β glBindTexture is supported (β) in every single one of these OpenGL versions:
2.0β2.1β3.0β3.1β3.2β3.3β4.0β4.1β4.2β4.3β4.4β4.5β
all checks, no notes, she's been booked and busy since 2.0 π β¨
π¦ SEE ALSO
glDeleteTextures(), glGenTextures(), glGet(), glGetTexParameter(), glIsTexture(), glTexImage1D(), glTexImage2D(), glTexImage2DMultisample(), glTexImage3D(), glTexImage3DMultisample(), glTexBuffer(), glTexParameter()
go read those next, bestie, they're all part of the same friend group πΈ
π 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 http://oss.sgi.com/projects/FreeB/.
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group
okay that's the whole page, mwah π β this little drop came from [FIXME: source] and it's dated 08/09/2021, so if you're reading this in the future, know that your girl was out here binding textures with the 2021 energy. stay iconic, go bind something πβ¨π«Ά
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms