GLBUFFERDATA(3G)
GLBUFFERDATA β the <3G> manual page, but make it cute β¨
okay bestie, this is the <3G> manual page, and itβs lowkey all about giving a buffer object a brand-new little data store. main character energy only π
β¨ NAME β¨
glBufferData, glNamedBufferData β creates and initializes a buffer object's data store. periodt.
π» C SPECIFICATION π»
void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
GLenum usage);
void glNamedBufferData(GLuint buffer, GLsizeiptr size, const void *data,
GLenum usage);
π PARAMETERS π
targetβ Specifies the target to which the buffer object is bound forglBufferData, which must be one of the buffer binding targets in the following table. The buffer binding targets and their purposes are: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 theglNamedBufferDatafunction.sizeβ Specifies the size in bytes of the buffer object's new data store.dataβ Specifies a pointer to data that will be copied into the data store for initialization, orNULLif no data is to be copied.usageβ Specifies the expected usage pattern of the data store. The symbolic constant must beGL_STREAM_DRAW,GL_STREAM_READ,GL_STREAM_COPY,GL_STATIC_DRAW,GL_STATIC_READ,GL_STATIC_COPY,GL_DYNAMIC_DRAW,GL_DYNAMIC_READ, orGL_DYNAMIC_COPY.
π¦ DESCRIPTION π¦
glBufferData and glNamedBufferData create a new data store for a buffer object. In case of glBufferData, the buffer object currently bound to target is used. For glNamedBufferData, a buffer object associated with ID specified by the caller in buffer will be used instead.
While creating the new storage, any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage. If data is not NULL, the data store is initialized with data from this pointer. In its initial state, the new data store is not mapped, it has a NULL mapped pointer, and its mapped access is GL_READ_WRITE.
usage is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. usage can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The frequency of access may be one of these:
STREAMβ The data store contents will be modified once and used at most a few times.STATICβ The data store contents will be modified once and used many times.DYNAMICβ The data store contents will be modified repeatedly and used many times.
The nature of access may be one of these:
DRAWβ The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.READβ The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.COPYβ The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
π NOTES π
- If
dataisNULL, a data store of the specifiedsizeis still created, but its contents remain uninitialized and thus undefined. no cap, that means donβt count on whatβs inside. - Clients must align data elements consistently with the requirements of the client platform, with an additional base-level requirement that an offset within a buffer to a datum comprising N bytes be a multiple of N.
- The
GL_ATOMIC_COUNTER_BUFFERtarget is available only if the GL version is4.2or greater. - The
GL_DISPATCH_INDIRECT_BUFFERandGL_SHADER_STORAGE_BUFFERtargets are available only if the GL version is4.3or greater. - The
GL_QUERY_BUFFERtarget is available only if the GL version is4.4or greater.
π ERRORS π
GL_INVALID_ENUMis generated byglBufferDataiftargetis not one of the accepted buffer targets.GL_INVALID_ENUMis generated ifusageis notGL_STREAM_DRAW,GL_STREAM_READ,GL_STREAM_COPY,GL_STATIC_DRAW,GL_STATIC_READ,GL_STATIC_COPY,GL_DYNAMIC_DRAW,GL_DYNAMIC_READ, orGL_DYNAMIC_COPY.GL_INVALID_VALUEis generated ifsizeis negative.GL_INVALID_OPERATIONis generated byglBufferDataif the reserved buffer object name0is bound totarget.GL_INVALID_OPERATIONis generated byglNamedBufferDataifbufferis not the name of an existing buffer object.GL_INVALID_OPERATIONis generated if theGL_BUFFER_IMMUTABLE_STORAGEflag of the buffer object isGL_TRUE.GL_OUT_OF_MEMORYis generated if the GL is unable to create a data store with the specifiedsize.
π ASSOCIATED GETS π
glGetBufferSubData()glGetBufferParameter()with argumentGL_BUFFER_SIZEorGL_BUFFER_USAGE
π VERSION SUPPORT π
OpenGL Version columns: 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5.
- Function / Feature Name:
glBufferDataβ2.0β,2.1β,3.0β,3.1β,3.2β,3.3β,4.0β,4.1β,4.2β,4.3β,4.4β,4.5β - Function / Feature Name:
glNamedBufferDataβ2.0-,2.1-,3.0-,3.1-,3.2-,3.3-,4.0-,4.1-,4.2-,4.3-,4.4-,4.5β
π« SEE ALSO π«
okay so like, go read these next, they're literally the rest of the buffer saga and you need them:
glBindBuffer()glBufferSubData()glMapBuffer()glUnmapBuffer()
that's the whole friend group fr fr β bind it, sub-data it, map it, unmap it. slay π
π COPYRIGHT π
first copyright block, copy-pasted with love (and legally required precision, ngl):
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/.
and there's a second copyright block too, because of course there is β the way this page has two of them is giving "extra credit energy" β¨
Copyright Β© 2005 Sams Publishing Copyright Β© 2010-2014 Khronos Group
πΈ and that's the whole page bestie, you're done, go touch some grass (after you call glUnmapBuffer(), obviously) π¦
little sign-off moment: this was GLBUFFERDATA(3G), dated 08/09/2021, and the source field literally says [FIXME: source] β not me clocking that the manpage itself has an unresolved FIXME π iconic behavior, truly. mwah π
π¦ 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