glMapBuffer, glMapNamedBuffer — map all of a buffer object's data store into the client's address space
Specifies the target to which the buffer object is bound
glMapBuffer, which must be one
of the buffer binding targets in the following table:
|Buffer Binding Target||Purpose|
||Atomic counter storage|
||Buffer copy source|
||Buffer copy destination|
||Indirect compute dispatch commands|
||Indirect command arguments|
||Vertex array indices|
||Pixel read target|
||Texture data source|
||Query result buffer|
||Read-write storage for shaders|
||Texture data buffer|
||Transform feedback buffer|
||Uniform block storage|
Specifies the name of the buffer object for
Specifies the access policy for
whether it will be possible to read from, write to, or
both read from and write to the buffer object's mapped
data store. The symbolic constant must be
glMapNamedBuffer map the entire data store
of a specified buffer object into the client's address space.
The data can then be directly read and/or written relative to
the returned pointer, depending on the specified
A pointer to the beginning of the mapped range is returned once
all pending operations on that buffer object have completed, and
may be used to modify and/or query the corresponding range of
the data store according to the value of
GL_READ_ONLY indicates that
the returned pointer may be used to read buffer
GL_WRITE_ONLY indicates that
the returned pointer may be used to modify buffer
GL_READ_WRITE indicates that
the returned pointer may be used to read and to
modify buffer object data.
If an error is generated, a
NULL pointer is
If no error occurs, the returned pointer will reflect an
allocation aligned to the value of
GL_MIN_MAP_BUFFER_ALIGNMENT basic machine
The returned pointer values may not be passed as parameter values to GL commands. For example, they may not be used to specify array pointers, or to specify or query pixel or texture image data; such actions produce undefined results, although implementations may not check for such behavior for performance reasons.
No GL error is generated if the returned pointer is accessed in
a way inconsistent with
access (e.g. used
to read from a mapping made with
GL_WRITE_ONLY or write to a mapping made
GL_READ_ONLY), but the result is undefined
and system errors (possibly including program termination) may
Mappings to the data stores of buffer objects may have
nonstandard performance characteristics. For example, such
mappings may be marked as uncacheable regions of memory, and in
such cases reading from them may be very slow. To ensure optimal
performance, the client should use the mapping in a fashion
for the buffer object and of
Using a mapping in a fashion inconsistent with these values is liable
to be multiple orders of magnitude slower than using normal memory.
Alignment of the returned pointer is guaranteed only if the
version of the GL version is 4.2 or greater. Also, the
GL_ATOMIC_COUNTER_BUFFER target is accepted
only if the GL version is 4.2 or greater.
GL_SHADER_STORAGE_BUFFER targets are
available only if the GL version is 4.3 or greater.
GL_QUERY_BUFFER target is available
only if the GL version is 4.4 or greater.
GL_INVALID_ENUM is generated by
target is not one of the buffer binding
targets listed above.
GL_INVALID_OPERATION is generated by
glMapBuffer if zero is bound to
GL_INVALID_OPERATION is generated by
buffer is not the name of an existing
GL_INVALID_ENUM is generated if
access is not
GL_OUT_OF_MEMORY is generated if the GL is
unable to map the buffer object's data store. This may occur for
a variety of system-specific reasons, such as the absence of
sufficient remaining virtual memory.
GL_INVALID_OPERATION is generated if the
buffer object is in a mapped state.
GL_MIN_MAP_BUFFER_ALIGNMENT. The value must
be a power of two that is at least 64.
|Function / Feature Name||2.0||2.1||3.0||3.1||3.2||3.3||4.0||4.1||4.2||4.3||4.4||4.5|
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. https://opencontent.org/openpub/.