Home

glMapBuffer

glMapBuffer is an OpenGL API function that maps the data store of a bound buffer object into the client's address space. By obtaining a pointer to the buffer’s memory, applications can read or modify the buffer contents directly without issuing subdata calls. The mapping is performed for the entire data store of the bound buffer object.

To use glMapBuffer, a buffer object must be bound to a target such as GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER,

The function returns a pointer to the mapped memory. If mapping fails, a NULL pointer is returned,

glMapBuffer is related to glMapBufferRange, which provides more granular control by allowing mapping of a subrange

Notes and caveats: mapping can incur performance costs due to synchronization with the GPU, and the mapped

or
other
buffer
targets
that
support
mapping.
The
access
parameter
indicates
how
the
mapped
memory
will
be
used
by
the
client;
common
values
are
GL_READ_ONLY
for
read
access
and
GL_WRITE_ONLY
for
write
access.
In
practice,
if
both
read
and
write
access
are
needed,
glMapBufferRange
with
appropriate
flags
is
often
preferred.
and
no
memory
is
mapped.
After
the
client
is
finished
accessing
the
data,
glUnmapBuffer
must
be
called
with
the
same
target.
If
the
buffer
contents
are
modified,
the
unmapping
step
ensures
the
changes
are
visible
to
the
GPU.
Some
implementations
may
require
synchronization
or
may
stall
the
CPU
if
the
GPU
is
actively
using
the
buffer.
of
a
buffer
and
supports
additional
flags
to
influence
behavior
and
performance,
such
as
invalidation
or
flushing
ranges.
pointer
becomes
invalid
after
unmapping
or
buffer
data
changes.
Access
permissions
and
availability
can
vary
by
OpenGL
version
and
extensions.