GLCLEARBUFFERSUBDATA(3G)
okay bestie, welcome to the GLCLEARBUFFERSUBDATA(3G) page. the header is literally giving [FIXME: manual] (not me, the manpage said it π), and the whole vibe is fill all or part of a buffer object's data store with a fixed value. no cap.
β¨ NAME β¨
glClearBufferSubData, glClearNamedBufferSubData β fill all or part of buffer object's data store with a fixed value. periodt.
π§Ύ C SPECIFICATION π§Ύ
void glClearBufferSubData(GLenum target, GLenum internalformat,
GLintptr offset, GLsizeiptr size,
GLenum format, GLenum type,
const void * data);
void glClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
GLintptr offset, GLsizeiptr size,
GLenum format, GLenum type,
const void *data);
π PARAMETERS π
targetβ specifies the target to which the buffer object is bound forglClearBufferSubData, which must be one of the buffer binding targets in the following list (the original had a table, but the facts are exactly the same):GL_ARRAY_BUFFERβ Vertex attributesGL_ATOMIC_COUNTER_BUFFERβ Atomic counter storageGL_COPY_READ_BUFFERβ Buffer copy sourceGL_COPY_WRITE_BUFFERβ Buffer copy destinationGL_DISPATCH_INDIRECT_BUFFERβ Indirect compute dispatch commandsGL_DRAW_INDIRECT_BUFFERβ Indirect command argumentsGL_ELEMENT_ARRAY_BUFFERβ Vertex array indicesGL_PIXEL_PACK_BUFFERβ Pixel read targetGL_PIXEL_UNPACK_BUFFERβ Texture data sourceGL_QUERY_BUFFERβ Query result bufferGL_SHADER_STORAGE_BUFFERβ Read-write storage for shadersGL_TEXTURE_BUFFERβ Texture data bufferGL_TRANSFORM_FEEDBACK_BUFFERβ Transform feedback bufferGL_UNIFORM_BUFFERβ Uniform block storage
bufferβ specifies the name of the buffer object forglClearNamedBufferSubData.internalformatβ the internal format with which the data will be stored in the buffer object.offsetβ the offset in basic machine units into the buffer object's data store at which to start filling.sizeβ the size in basic machine units of the range of the data store to fill.formatβ the format of the data in memory addressed bydata.typeβ the type of the data in memory addressed bydata.dataβ the address of a memory location storing the data to be replicated into the buffer's data store. that's the pointer bestie, it's giving address of the data to replicate π
π DESCRIPTION π
okay so picture this: glClearBufferSubData and glClearNamedBufferSubData are the besties that fill a specified region of a buffer object's data store with data straight from client memory. no middleman, no drama, just vibes going directly into your buffer π
offset and size are the main characters here β they specify the extent of the region within the data store of the buffer object that you're gonna fill with data. think of them as the "where" and "how much" of the whole operation β¨
So the data starts out living in client memory, supplied in a format specified by format, in data type type. It gets read from the memory address given by data, and then converted into the internal representation given by internalformat β which, and this is the important part bestie, must be one of the following sized internal formats π
βββββββββββββββ¬ββββββββββββ¬βββββββββββββ¬βββββββ¬ββββββββββββββββ
β β β β β Component β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββ¬ββββ¬ββββ¬ββββ€
β Sized β Base Type β Components β Norm β 0 β 1 β 2 β 3 β
β Internal β β β β β β β β
β Format β β β β β β β β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R8 β ubyte β 1 β YES β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R16 β ushort β 1 β YES β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R16F β half β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R32F β float β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R8I β byte β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R16I β short β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R32I β int β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R8UI β ubyte β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R16UI β ushort β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_R32UI β uint β 1 β NO β R β 0 β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG8 β ubyte β 2 β YES β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG16 β ushort β 2 β YES β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG16F β half β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG32F β float β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG8I β byte β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG16I β short β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG32I β int β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG8UI β ubyte β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG16UI β ushort β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RG32UI β uint β 2 β NO β R β G β 0 β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGB32F β float β 3 β NO β R β G β B β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGB32I β int β 3 β NO β R β G β B β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGB32UI β uint β 3 β NO β R β G β B β 1 β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA8 β uint β 4 β YES β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA16 β short β 4 β YES β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA16F β half β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA32F β float β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA8I β byte β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA16I β short β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA32I β int β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA8UI β ubyte β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA16UI β ushort β 4 β NO β R β G β B β A β
βββββββββββββββΌββββββββββββΌβββββββββββββΌβββββββΌββββΌββββΌββββΌββββ€
β GL_RGBA32UI β uint β 4 β NO β R β G β B β A β
βββββββββββββββ΄ββββββββββββ΄βββββββββββββ΄βββββββ΄ββββ΄ββββ΄ββββ΄ββββ
like, that's the whole guest list π columns are Sized Internal Format, Base Type, Components, Norm, and then the Component slots 0, 1, 2, 3 β every row is serving its own little R/G/B/A lineup π no gatekeeping, all 40-ish formats are up there, go wild (within the list, bestie, it says must be)
And then β¨ the moment we've all been waiting for β¨ β that converted data gets replicated throughout the specified region of the buffer object's data store. yes, the whole region. it's giving main character energy across the entire range π¦
and here's the cute lil plot twist: if data is NULL, then the subrange of the buffer's data store is filled with zeros π«Ά so you don't even need to bring data to the function β it'll still hand you a freshly-zeroed region like the icon it is π
heads up bestie:databeingNULLisn't an error, it's literally a whole feature β zero-fill mode, no cap π₯
π ERRORS π
okay bestie, this is the part where OpenGL yells at you. every single one of these is a real thing that can happen, so let's get into it π
GL_INVALID_ENUMβ thrown byglClearBufferSubDatawhen target isn't one of the generic buffer binding targets. wrong target, wrong vibe, immediate no πGL_INVALID_VALUEβ thrown byglClearBufferSubDatawhen there's no buffer bound to target. like babe, you have to actually bind something first πGL_INVALID_OPERATIONβ thrown byglClearNamedBufferSubDatawhen buffer isn't the name of an existing buffer object. if the name doesn't exist, we can't clear it, that's just how it is π«ΆGL_INVALID_ENUMβ thrown when internalformat isn't one of the valid sized internal formats listed in the table above. check the table, bestie, it's right there β¨GL_INVALID_VALUEβ thrown when offset or range aren't multiples of the number of basic machine units per-element for the internal format specified by internalformat. the manpage literally tells you how to compute it: multiply the number of components for internalformat from the table by the size of the base type from the table. do the math, slay π₯GL_INVALID_VALUEβ thrown when offset or size is negative, or when$offset + size$is greater than the value ofGL_BUFFER_SIZEfor the buffer object. no negative numbers, no going out of bounds, no cap π«GL_INVALID_OPERATIONβ thrown when any part of the specified range of the buffer object is mapped withglMapBufferRange()orglMapBuffer(), unless it was mapped with theGL_MAP_PERSISTENT_BITbit set in theglMapBufferRangeaccess flags. like you cannot clear a thing while it's mapped unless it's persistent-mapped, periodt πGL_INVALID_VALUEβ thrown when format isn't a valid format, or type isn't a valid type. two separate ways to fumble, iconic of them ngl π
β¨ VERSION SUPPORT β¨
okay so this is the whole "which OpenGL version actually has this" chart, and i'm keeping it exactly as-is because you need to read it, not hear me describe it π
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β OpenGL Version β
βββββββββββββββββββββββββββββΌββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ€
β Function β 2.0 β 2.1 β 3.0 β 3.1 β 3.2 β 3.3 β 4.0 β 4.1 β 4.2 β 4.3 β 4.4 β 4.5 β
β / β β β β β β β β β β β β β
β Feature β β β β β β β β β β β β β
β Name β β β β β β β β β β β β β
βββββββββββββββββββββββββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββ€
β glClearBufferSubData β - β - β - β - β - β - β - β - β - β β β β β β β
βββββββββββββββββββββββββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββ€
β glClearNamedBufferSubData β - β - β - β - β - β - β - β - β - β - β - β β β
βββββββββββββββββββββββββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ
so like, glClearBufferSubData shows up starting at OpenGL 4.3 and hangs around for 4.4 and 4.5 β everything before that is a dash, as in absolutely not available π and glClearNamedBufferSubData? that one is a 4.5-only situation, a true late bloomer, main character energy honestly π
πΈ SEE ALSO πΈ
glClearBufferData()β that's the one, go read it π¦
π COPYRIGHT π
Copyright Β© 2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 2014 Khronos Group
okay bestie that's the whole page, we did it π this cutie was served up from <pink>[FIXME: source]</pink>, dated <purple>08/09/2021</purple>, and it lives at <hotpink>GLCLEARBUFFERSUBDATA(3G)</hotpink> β go clear some buffers, you're gonna 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