GLCLEARTEXSUBIMAGE(3G)
π GLCLEARTEXSUBIMAGE (3G)
okay so bestie, welcome to the glClearTexSubImage page β it's the OpenGL 3G manual, and honestly? it ate. it's giving "paint bucket but make it 3D" and i'm obsessed. let's get into it β¨
πΈ NAME πΈ
glClearTexSubImage β fills all or part of a texture image with a constant value π
π C SPECIFICATION π
void glClearTexSubImage(GLuint texture, GLint level, GLint xoffset,
GLint yoffset, GLint zoffset, GLsizei width,
GLsizei height, GLsizei depth, GLenum format,
GLenum type, const void * data);
like, copy that exactly, no cap π«Ά
π¦ PARAMETERS π¦
textureβ the name of an existing texture object that's holding the image you wanna clear. it has to already exist, mmkay?levelβ which mip level of the texture has the region you're clearing.xoffsetβ the coordinate of the left edge of the region to be cleared.yoffsetβ the coordinate of the lower edge of the region to be cleared.zoffsetβ the coordinate of the front of the region to be cleared.widthβ how wide the region to be cleared is.heightβ how tall the region to be cleared is.depthβ how deep the region to be cleared is.formatβ the format of the data whose address in memory is given bydata. iykyk.typeβ the type of the data whose address in memory is given bydata.dataβ the address in memory of the data that's gonna be used to clear the specified region.
β¨ DESCRIPTION β¨
glClearTexSubImage fills all or part of an image inside a texture with a value your app supplies. lowkey iconic behavior π
texture must be the name of an existing texture. also β and this is the important part β texture may not be the name of a buffer texture, and its internal format may not be compressed. those are hard no's π«
the arguments xoffset, yoffset, and zoffset specify the lower left texel coordinates of a width-wide by height-high by depth-deep rectangular subregion of the texel array. like a little box carved out of the big box π¦
π§ how offsets work for the funky texture types
- for one-dimensional array textures,
yoffsetis interpreted as the first layer to be cleared, andheightis the number of layers to clear. - for two-dimensional array textures,
zoffsetis interpreted as the first layer to be cleared, anddepthis the number of layers to clear. - cube map textures are treated as an array of six slices in the z-dimension β
zoffsetis interpreted as specifying the cube map face for the corresponding layer, anddepthis the number of faces to clear. - for cube map array textures,
zoffsetis the first layer-face to clear, anddepthis the number of layer-faces to clear. each layer-face gets translated into an array layer and a cube map face as described in the OpenGL Specification. (go read it, i believe in you π)
π the border math (brace yourself)
negative values of xoffset, yoffset, and zoffset correspond to the coordinates of border texels. take ws, hs, ds, wb, hb, and db to be the specified width, height, depth, and the border width, border height, and border depth of the texel array, and take x, y, z, w, h, and d to be the xoffset, yoffset, zoffset, width, height, and depth argument values.
any of the following relationships generates a GL_INVALID_OPERATION error π:
x < -wb
x + w > ws - wb
y < -hb
y + h > hs - hb
z < -db
z + d > ds - db
bestie please check your math before you call this. that's six separate ways to get a GL_INVALID_OPERATION and none of them are cute π
π dimensions you don't have
for texture types that don't have certain dimensions, this command treats those dimensions as having a size of 1. for example β to clear a portion of a two-dimensional texture, use zoffset equal to zero and depth equal to one. that's the move π
π format, type, and the data itself
format and type specify the format and type of the source data, and they're interpreted exactly as they are for glTexImage3D(). keep that in mind, it's the whole vibe.
matchups, and you do have to match:
- textures with a base internal format of
GL_DEPTH_COMPONENT,GL_STENCIL_INDEX, orGL_DEPTH_STENCILrequire depth component, stencil, or depth-stencil component data respectively. - textures with other base internal formats require RGBA formats.
- textures with integer internal formats require integer data.
data is a pointer to an array of between one and four components of texel data, and that's what gets used as the source for the constant fill value. the GL converts the elements of data into the internal format of the texture image (the one that was specified when the level was defined by any of the glTexImage*, glTexStorage* or glCopyTexImage* commands), and then uses them to fill the specified range of the destination texture level. slay π
- if
dataisNULL, the pointer is ignored and the sub-range of the texture image gets filled with zeros. free real estate β¨ - if
textureis a multisample texture, all the samples in a texel get cleared to the value specified bydata.
π«Ά NOTES π«Ά
glClearTexSubImage is available only if the GL version is 4.4 or greater. no 4.4, no function, that's the rule π
π₯ ERRORS π₯
buckle up, there's a whole list of ways to make the GL mad at you π€
GL_INVALID_OPERATIONis generated iftextureis zero or not the name of an existing texture object.GL_INVALID_OPERATIONis generated iftextureis a buffer texture.GL_INVALID_OPERATIONis generated iftexturehas a compressed internal format.GL_INVALID_OPERATIONis generated if the base internal format isGL_DEPTH_COMPONENTandformatis notGL_DEPTH_COMPONENT.GL_INVALID_OPERATIONis generated if the base internal format isGL_DEPTH_STENCILandformatis notGL_DEPTH_STENCIL.GL_INVALID_OPERATIONis generated if the base internal format isGL_STENCIL_INDEXandformatis notGL_STENCIL_INDEX.GL_INVALID_OPERATIONis generated if the base internal format isGL_RGBAandformatisGL_DEPTH_COMPONENT,GL_STENCIL_INDEX, orGL_DEPTH_STENCIL.GL_INVALID_OPERATIONis generated if the internal format is integer andformatdoes not specify integer data.GL_INVALID_OPERATIONis generated if the internal format is not integer andformatspecifies integer data.GL_INVALID_OPERATIONerror is generated if thexoffset,yoffset,zoffset,width,height, anddepthparameters (or combinations thereof) specify a region that falls outside the defined texture image array (including border, if any).
fr fr, that last one is the sneaky one. stay inside the array, bestie π«Ά
π ASSOCIATED GETS π
glGetTexImage(), glGetInternalformat()
π VERSION SUPPORT π
the vibe check, version by version:
glClearTexSubImagein OpenGL 2.0 β-(nope)- in 2.1 β
- - in 3.0 β
- - in 3.1 β
- - in 3.2 β
- - in 3.3 β
- - in 4.0 β
- - in 4.1 β
- - in 4.2 β
- - in 4.3 β
- - in 4.4 β β (finally!! main character energy β)
- in 4.5 β β
π SEE ALSO π
glClearTexImage(), glTexStorage1D(), glTexStorage2D(), glTexStorage3D(), glTexImage1D(), glTexImage2D(), glTexImage3D()
part 2 is coming, don't go anywhere π
π COPYRIGHT
Okay so the legal bit, and yes we're doing it, because respecting licenses is the most main-character thing you can do π
This material is Copyright Β© 2013-2014 Khronos Group. and it may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. That license lives at http://opencontent.org/openpub/ β go read it if you're curious, it's giving "required reading" energy β¨
π COPYRIGHT <small>(yes, again β they really said it twice)</small>
Copyright Β© 2013-2014 Khronos Group
That's it. That's the whole section. Short, sweet, legally binding. Periodt π
And that's a wrap on the whole page, bestie!! π¦ You made it to the very end, I'm so proud ππ«Ά
Cute little sign-off: the source line reads [FIXME: source] (yes, the docs themselves are out here with a TODO, relatable honestly π), the version/date stamp is 08/09/2021, and the whole thing is filed under GLCLEARTEXSUBIMAGE(3G). Now go clear some texture sub-images β slay πβ¨
π¦ 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