GLUNMAPBUFFER(3G)
π GLUNMAPBUFFER(3G) β bestie edition π
okay so this is the page for glUnmapBuffer and glUnmapNamedBuffer from section 3G of the manual, and honestly? it's giving "cleanup era." β¨
πΈ NAME πΈ
glUnmapBuffer, glUnmapNamedBuffer β release the mapping of a buffer object's data store into the client's address space
like, you mapped it, you did your thing, now you're letting it go. closure. π¦
β¨ C SPECIFICATION β¨
GLboolean glUnmapBuffer(GLenum target);
GLboolean glUnmapNamedBuffer(GLuint buffer);
bestie they literally both return a GLboolean, we love a consistent king π
π PARAMETERS π
- target β specifies the target to which the buffer object is bound for
glUnmapBuffer, which must be one of the buffer binding targets in the following table: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 for
glUnmapNamedBuffer. π that's the whole job. name. that's it.
π DESCRIPTION π
glUnmapBuffer and glUnmapNamedBuffer unmap (release) any mapping of a specified buffer object into the client's address space (see glMapBufferRange() and glMapBuffer()). no cap, that's literally the function. you're un-mapping. the end of the situationship π
okay but here's the serious part so listen up π β if a mapping is not unmapped before the corresponding buffer object's data store is used by the GL, an error will be generated by any GL command that attempts to dereference the buffer object's data store, unless the buffer was successfully mapped with GL_MAP_PERSISTENT_BIT (see glMapBufferRange()). when a data store is unmapped, the mapped pointer becomes invalid. β οΈ like, that pointer? gone. deceased. do not touch it.
glUnmapBuffer returns GL_TRUE unless the data store contents have become corrupt during the time the data store was mapped. This can occur for system-specific reasons that affect the availability of graphics memory, such as screen mode changes. In such situations, GL_FALSE is returned and the data store contents are undefined. An application must detect this rare condition and reinitialize the data store. π so rare but so real β your app HAS to check for it, i don't make the rules.
slayful convenience note: a buffer object's mapped data store is automatically unmapped when the buffer object is deleted or its data store is recreated with glBufferData()). so sometimes the universe handles it for you π«Ά
π NOTES π
- If an error is generated,
glUnmapBufferreturnsGL_FALSE. (yes, the error case lies to your face with aGLboolean. π) - The
GL_ATOMIC_COUNTER_BUFFERtarget is accepted 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 gating is so real, check yours before you come for these targets π
π ERRORS π
GL_INVALID_ENUMis generated byglUnmapBufferif target is not one of the buffer binding targets listed above. π wrong target bestie.GL_INVALID_OPERATIONis generated byglUnmapBufferif zero is bound to target. nothing bound? nothing to unmap.GL_INVALID_OPERATIONis generated byglUnmapNamedBufferif buffer is not the name of an existing buffer object. bestie that buffer does not exist, i'm sorry πGL_INVALID_OPERATIONis generated if the buffer object is not in a mapped state. you can't unmap what was never mapped, that's not how any of this works π
π ASSOCIATED GETS π
glGetBufferParameter() with argument GL_BUFFER_MAPPED. use it to vibe check whether your buffer is mapped fr fr β
π VERSION SUPPORT π
the columns run 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5 β and here's how the two functions ate:
glUnmapBufferβ β in every version:2.0β,2.1β,3.0β,3.1β,3.2β,3.3β,4.0β,4.1β,4.2β,4.3β,4.4β,4.5β. iconic, timeless, never missed a single one πglUnmapNamedBufferβ only4.5gets the β.2.0-,2.1-,3.0-,3.1-,3.2-,3.3-,4.0-,4.1-,4.2-,4.3-,4.4-,4.5β. fashionably late but she arrived π
πΈ SEE ALSO πΈ
glBufferData()glDeleteBuffers()glMapBuffer()glMapBufferRange()
the whole friend group honestly π«Ά
π COPYRIGHT π
Copyright Β© 2005 Addison-Wesley. Copyright Β© 2010-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 Addison-Wesley Group Copyright Β© 2010-2014 Khronos Group
yes the copyright section appears twice in the original and yes i kept it twice. every detail stays, that's the rule π
alright bestie, that's the whole page β source was [FIXME: source] and the date on this one is 08/09/2021, so go forth, unmap your buffers, check your GLboolean, and remember: the pointer is invalid after. no cap. π¦β¨π
π¦ 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