GLGETBUFFERSUBDATA(3G)
π GLGETBUFFERSUBDATA(3G) β the girlies' guide β¨
okay so this is a page from the 3G manual (the OpenGL girlies know π), and it's literally all about glGetBufferSubData and glGetNamedBufferSubData. Come sit with me bestie, we're gonna read the data store together π«Ά
πΈ NAME πΈ
glGetBufferSubData, glGetNamedBufferSubData β returns a subset of a buffer object's data store. yeah. that's the whole vibe. it grabs a lil slice of your buffer's data and hands it to you π
β¨ C SPECIFICATION β¨
like, the actual signatures, no cap:
void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
GLvoid * data);
void glGetNamedBufferSubData(GLuint buffer, GLintptr offset,
GLsizeiptr size, void *data);
π PARAMETERS π
so here's what you're feeding it:
targetβ specifies the target to which the buffer object is bound forglGetBufferSubData, which must be one of the buffer binding targets in the following table. and like, obvi I'm putting it in a list for u, tables are so 2010s πGL_ARRAY_BUFFERβ vertex attributes πGL_ATOMIC_COUNTER_BUFFERβ atomic counter storage βGL_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 forglGetNamedBufferSubData. the name!! as in, the buffer's name, bestie π·οΈoffsetβ specifies the offset into the buffer object's data store from which data will be returned, measured in bytes. yes, bytes. count them carefully π§sizeβ specifies the size in bytes of the data store region being returned πdataβ specifies a pointer to the location where buffer object data is returned. it's giving "you provide the empty cup, GL pours the juice" π
π¦ DESCRIPTION π¦
glGetBufferSubData and glGetNamedBufferSubData return some or all of the data contents of the data store of the specified buffer object. literally some or all, your choice, main character energy π
Data starting at byte offset and extending for size bytes is copied from the buffer object's data store to the memory pointed to by data.
An error is thrown if the buffer object is currently mapped, or ifoffsetandsizetogether define a range beyond the bounds of the buffer object's data store. like, don't try it π
π NOTES π
- If an error is generated, no change is made to the contents of
data. so your buffer's still your buffer, no harm done π«Ά - The
GL_ATOMIC_COUNTER_BUFFERtarget is available only if the GL version is 4.2 or greater. - The
GL_DISPATCH_INDIRECT_BUFFERandGL_SHADER_STORAGE_BUFFERtargets are available only if the GL version is 4.3 or greater. - The
GL_QUERY_BUFFERtarget is available only if the GL version is 4.4 or greater.
(version gatekeeping, honestly. we've all been there π)
π ERRORS π
the "not me generating an error" moments, let's go:
GL_INVALID_ENUMis generated byglGetBufferSubDataiftargetis not one of the generic buffer binding targets.GL_INVALID_OPERATIONis generated byglGetBufferSubDataif zero is bound totarget. zero is literally nothing, bestie, you gotta bind something πGL_INVALID_OPERATIONis generated byglGetNamedBufferSubDataifbufferis not the name of an existing buffer object.GL_INVALID_VALUEis generated ifoffsetorsizeis negative, or if $offset + size$ is greater than the value ofGL_BUFFER_SIZEfor the buffer object.GL_INVALID_OPERATIONis generated if the buffer object is mapped withglMapBufferRange()orglMapBuffer(), unless it was mapped with theGL_MAP_PERSISTENT_BITbit set in theglMapBufferRangeaccess flags.
π VERSION SUPPORT π
the compatibility glow-up timeline β¨ (yes I'm listing every single one, we don't skip here)
glGetBufferSubDataβ supported in: 2.0 β, 2.1 β, 3.0 β, 3.1 β, 3.2 β, 3.3 β, 4.0 β, 4.1 β, 4.2 β, 4.3 β, 4.4 β, 4.5 βglGetNamedBufferSubDataβ supported in: 2.0 -, 2.1 -, 3.0 -, 3.1 -, 3.2 -, 3.3 -, 4.0 -, 4.1 -, 4.2 -, 4.3 -, 4.4 -, 4.5 β
so like glGetNamedBufferSubData only showed up for 4.5. iconic of her honestly, fashionably late π
π SEE ALSO π
go read these next, iykyk:
glBindBuffer(), glBufferData(), glBufferSubData(), glMapBuffer(), glUnmapBuffer()
π COPYRIGHT π
Copyright Β© 2005 Addison-Wesley. Copyright Β© 2011-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 Β© 2005 Sams Publishing Copyright Β© 2011-2014 Khronos Group
and that's the page babes π it's from [FIXME: source], version dated 08/09/2021, and it goes out to the whole GLGETBUFFERSUBDATA(3G) crew. slay, go read your buffers responsibly β¨ππ¦
π¦ 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