2009-03-08 00:46:58 +00:00
<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry id= "glMapBuffer" >
2013-11-03 11:43:50 +00:00
<refentryinfo >
<copyright >
<year > 2013</year>
<holder > Khronos Group</holder>
</copyright>
<copyright >
<year > 2010-2013</year>
<holder > Khronos Group</holder>
</copyright>
</refentryinfo>
2009-03-08 00:46:58 +00:00
<refmeta >
<refentrytitle > glMapBuffer</refentrytitle>
<manvolnum > 3G</manvolnum>
</refmeta>
<refnamediv >
<refname > glMapBuffer</refname>
<refpurpose > map a buffer object's data store</refpurpose>
</refnamediv>
<refsynopsisdiv > <title > C Specification</title>
<funcsynopsis >
<funcprototype >
<funcdef > void * <function > glMapBuffer</function> </funcdef>
<paramdef > GLenum <parameter > target</parameter> </paramdef>
<paramdef > GLenum <parameter > access</parameter> </paramdef>
</funcprototype>
</funcsynopsis>
2013-11-03 11:43:50 +00:00
<funcsynopsis >
<funcprototype >
<funcdef > GLboolean <function > glUnmapBuffer</function> </funcdef>
<paramdef > GLenum <parameter > target</parameter> </paramdef>
</funcprototype>
</funcsynopsis>
2009-03-08 00:46:58 +00:00
</refsynopsisdiv>
<refsect1 id= "parameters" > <title > Parameters</title>
<variablelist >
<varlistentry >
<term > <parameter > target</parameter> </term>
<listitem >
<para >
Specifies the target buffer object being mapped.
The symbolic constant must be
<constant > GL_ARRAY_BUFFER</constant> ,
2013-10-23 18:17:08 +00:00
<constant > GL_ATOMIC_COUNTER_BUFFER</constant> ,
2010-11-21 14:34:29 +00:00
<constant > GL_COPY_READ_BUFFER</constant> ,
<constant > GL_COPY_WRITE_BUFFER</constant> ,
2013-10-23 18:17:08 +00:00
<constant > GL_DRAW_INDIRECT_BUFFER</constant> ,
<constant > GL_DISPATCH_INDIRECT_BUFFER</constant> ,
2009-03-08 00:46:58 +00:00
<constant > GL_ELEMENT_ARRAY_BUFFER</constant> ,
2010-11-21 14:34:29 +00:00
<constant > GL_PIXEL_PACK_BUFFER</constant> ,
<constant > GL_PIXEL_UNPACK_BUFFER</constant> ,
2013-10-23 18:17:08 +00:00
<constant > GL_QUERY_BUFFER</constant> ,
<constant > GL_SHADER_STORAGE_BUFFER</constant> ,
2010-11-21 14:34:29 +00:00
<constant > GL_TEXTURE_BUFFER</constant> ,
<constant > GL_TRANSFORM_FEEDBACK_BUFFER</constant> or
<constant > GL_UNIFORM_BUFFER</constant> .
2009-03-08 00:46:58 +00:00
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <parameter > access</parameter> </term>
<listitem >
<para >
2013-11-03 11:43:50 +00:00
For <function > glMapBuffer</function> only,
specifies the access policy, indicating whether it will be possible to read from, write to,
2009-03-08 00:46:58 +00:00
or both read from and write to the buffer object's mapped data store. The symbolic constant must be
<constant > GL_READ_ONLY</constant> , <constant > GL_WRITE_ONLY</constant> , or <constant > GL_READ_WRITE</constant> .
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id= "description" > <title > Description</title>
<para >
2013-11-03 11:43:50 +00:00
<function > glMapBuffer</function> maps to the client's address space the entire data store of the buffer object
currently bound to <parameter > target</parameter> . The data can then be directly read and/or written relative to
2009-03-08 00:46:58 +00:00
the returned pointer, depending on the specified <parameter > access</parameter> policy. If the GL is unable to
2013-11-03 11:43:50 +00:00
map the buffer object's data store, <function > glMapBuffer</function> generates an error and returns
2009-03-08 00:46:58 +00:00
<constant > NULL</constant> . This may occur for system-specific reasons, such as low virtual memory availability.
2013-10-23 18:17:08 +00:00
If no error occurs, the returned pointer will have an alignment of at least <constant > GL_MIN_MAP_BUFFER_ALIGNMENT</constant>
basic machine units. The value of <constant > GL_MIN_MAP_BUFFER_ALIGNMENT</constant> can be retrieved by calling
<citerefentry > <refentrytitle > glGet</refentrytitle> </citerefentry> with <parameter > pname</parameter> set to
<constant > GL_MIN_MAP_BUFFER_ALIGNMENT</constant> and must be a power of two that is at least 64.
2009-03-08 00:46:58 +00:00
</para>
<para >
If a mapped data store is accessed in a way inconsistent with the specified <parameter > access</parameter> policy,
2013-11-03 11:43:50 +00:00
no error is generated, but performance may be negatively impacted and system errors, including program
termination, may result. Unlike the <parameter > usage</parameter> parameter of <function > glBufferData</function> ,
2009-03-08 00:46:58 +00:00
<parameter > access</parameter> is not a hint, and does in fact constrain the usage of the mapped data store on
2013-11-03 11:43:50 +00:00
some GL implementations. In order to achieve the highest performance available, a buffer object's data store
should be used in ways consistent with both its specified <parameter > usage</parameter> and
2009-03-08 00:46:58 +00:00
<parameter > access</parameter> parameters.
</para>
<para >
A mapped data store must be unmapped with <function > glUnmapBuffer</function> before its buffer object is used.
Otherwise an error will be generated by any GL command that attempts to dereference the buffer object's data store.
When a data store is unmapped, the pointer to its data store becomes invalid. <function > glUnmapBuffer</function>
returns <constant > GL_TRUE</constant> 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, <constant > GL_FALSE</constant> is returned and the
data store contents are undefined. An application must detect this rare condition and reinitialize the data store.
</para>
<para >
2013-11-03 11:43:50 +00:00
A buffer object's mapped data store is automatically unmapped when the buffer object is deleted or its data store
2009-03-08 00:46:58 +00:00
is recreated with <function > glBufferData</function> .
</para>
</refsect1>
<refsect1 id= "notes" > <title > Notes</title>
<para >
If an error is generated, <function > glMapBuffer</function> returns <constant > NULL</constant> , and
<function > glUnmapBuffer</function> returns <constant > GL_FALSE</constant> .
</para>
<para >
Parameter values passed to GL commands may not be sourced from the returned pointer. No error will be generated,
but results will be undefined and will likely vary across GL implementations.
</para>
2013-10-23 18:17:08 +00:00
<para >
Alignment of the returned pointer is guaranteed only if the version
of the GL version is 4.2 or greater. Also, the <constant > GL_ATOMIC_COUNTER_BUFFER</constant>
target is accepted only if the GL version is 4.2 or greater.
</para>
<para >
The <constant > GL_DISPATCH_INDIRECT_BUFFER</constant> and <constant > GL_SHADER_STORAGE_BUFFER</constant> targets are available only if the GL version
is 4.3 or greater.
</para>
<para >
The <constant > GL_QUERY_BUFFER</constant> target is available only if the GL version is 4.4 or greater.
</para>
2009-03-08 00:46:58 +00:00
</refsect1>
<refsect1 id= "errors" > <title > Errors</title>
<para >
2010-11-21 14:34:29 +00:00
<constant > GL_INVALID_ENUM</constant> is generated if <parameter > target</parameter> is not
2013-10-23 18:17:08 +00:00
one of the accepted targets.
2009-03-08 00:46:58 +00:00
</para>
<para >
2013-11-03 11:43:50 +00:00
<constant > GL_INVALID_ENUM</constant> is generated if <parameter > access</parameter> is not
2009-03-08 00:46:58 +00:00
<constant > GL_READ_ONLY</constant> , <constant > GL_WRITE_ONLY</constant> , or <constant > GL_READ_WRITE</constant> .
</para>
<para >
<constant > GL_OUT_OF_MEMORY</constant> is generated when <function > glMapBuffer</function> is executed
2013-11-03 11:43:50 +00:00
if the GL is unable to map the buffer object's data store. This may occur for a variety of system-specific
2009-03-08 00:46:58 +00:00
reasons, such as the absence of sufficient remaining virtual memory.
</para>
<para >
<constant > GL_INVALID_OPERATION</constant> is generated if the reserved buffer object name 0 is bound to <parameter > target</parameter> .
</para>
<para >
<constant > GL_INVALID_OPERATION</constant> is generated if <function > glMapBuffer</function> is executed for
a buffer object whose data store is already mapped.
</para>
<para >
<constant > GL_INVALID_OPERATION</constant> is generated if <function > glUnmapBuffer</function> is executed for
a buffer object whose data store is not currently mapped.
</para>
</refsect1>
<refsect1 id= "associatedgets" > <title > Associated Gets</title>
<para >
<citerefentry > <refentrytitle > glGetBufferPointerv</refentrytitle> </citerefentry> with argument <constant > GL_BUFFER_MAP_POINTER</constant>
</para>
<para >
2010-11-21 14:34:29 +00:00
<citerefentry > <refentrytitle > glGetBufferParameter</refentrytitle> </citerefentry> with argument <constant > GL_BUFFER_MAPPED</constant> , <constant > GL_BUFFER_ACCESS</constant> , or <constant > GL_BUFFER_USAGE</constant>
2009-03-08 00:46:58 +00:00
</para>
</refsect1>
<refsect1 id= "seealso" > <title > See Also</title>
<para >
<citerefentry > <refentrytitle > glBindBuffer</refentrytitle> </citerefentry> ,
2010-11-21 14:34:29 +00:00
<citerefentry > <refentrytitle > glBindBufferBase</refentrytitle> </citerefentry> ,
<citerefentry > <refentrytitle > glBindBufferRange</refentrytitle> </citerefentry> ,
2009-03-08 00:46:58 +00:00
<citerefentry > <refentrytitle > glBufferData</refentrytitle> </citerefentry> ,
<citerefentry > <refentrytitle > glBufferSubData</refentrytitle> </citerefentry> ,
<citerefentry > <refentrytitle > glDeleteBuffers</refentrytitle> </citerefentry>
</para>
</refsect1>
<refsect1 id= "Copyright" > <title > Copyright</title>
<para >
2013-10-23 18:17:08 +00:00
Copyright <trademark class= "copyright" > </trademark> 2005 Addison-Wesley.
2013-11-03 11:43:50 +00:00
Copyright <trademark class= "copyright" > </trademark> 2010-2013 Khronos Group.
This material may be distributed subject to the terms and conditions set forth in
2009-03-08 00:46:58 +00:00
the Open Publication License, v 1.0, 8 June 1999.
<ulink url= "http://opencontent.org/openpub/" > http://opencontent.org/openpub/</ulink> .
</para>
</refsect1>
</refentry>