64ac1e3d52fb531922c36d4b90ce66f2b5d4494d
[clinton/guile-figl.git] / upstream-man-pages / man3 / glMapBufferRange.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id="glMapBufferRange">
5 <refmeta>
6 <refmetainfo>
7 <copyright>
8 <year>2010</year>
9 <holder>Khronos Group</holder>
10 </copyright>
11 </refmetainfo>
12 <refentrytitle>glMapBufferRange</refentrytitle>
13 <manvolnum>3G</manvolnum>
14 </refmeta>
15 <refnamediv>
16 <refname>glMapBufferRange</refname>
17 <refpurpose>map a section of a buffer object's data store</refpurpose>
18 </refnamediv>
19 <refsynopsisdiv><title>C Specification</title>
20 <funcsynopsis>
21 <funcprototype>
22 <funcdef>void *<function>glMapBufferRange</function></funcdef>
23 <paramdef>GLenum <parameter>target</parameter></paramdef>
24 <paramdef>GLintptr <parameter>offset</parameter></paramdef>
25 <paramdef>GLsizeiptr <parameter>length</parameter></paramdef>
26 <paramdef>GLbitfield <parameter>access</parameter></paramdef>
27 </funcprototype>
28 </funcsynopsis>
29 </refsynopsisdiv>
30 <refsect1 id="parameters"><title>Parameters</title>
31 <variablelist>
32 <varlistentry>
33 <term><parameter>target</parameter></term>
34 <listitem>
35 <para>
36 Specifies a binding to which the target buffer is bound.
37 </para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term><parameter>offset</parameter></term>
42 <listitem>
43 <para>
44 Specifies a the starting offset within the buffer of the range to be mapped.
45 </para>
46 </listitem>
47 </varlistentry>
48 <varlistentry>
49 <term><parameter>length</parameter></term>
50 <listitem>
51 <para>
52 Specifies a length of the range to be mapped.
53 </para>
54 </listitem>
55 </varlistentry>
56 <varlistentry>
57 <term><parameter>access</parameter></term>
58 <listitem>
59 <para>
60 Specifies a combination of access flags indicating the desired access to the range.
61 </para>
62 </listitem>
63 </varlistentry>
64 </variablelist>
65 </refsect1>
66 <refsect1 id="description"><title>Description</title>
67 <para>
68 <function>glMapBufferRange</function> maps all or part of the data store of a buffer object into the client's address
69 space. <parameter>target</parameter> specifies the target to which the buffer is bound and must be one of <constant>GL_ARRAY_BUFFER</constant>,
70 <constant>GL_COPY_READ_BUFFER</constant>, <constant>GL_COPY_WRITE_BUFFER</constant>, <constant>GL_ELEMENT_ARRAY_BUFFER</constant>,
71 <constant>GL_PIXEL_PACK_BUFFER</constant>, <constant>GL_PIXEL_UNPACK_BUFFER</constant>, <constant>GL_TEXTURE_BUFFER</constant>,
72 <constant>GL_TRANSFORM_FEEDBACK_BUFFER</constant>, or <constant>GL_UNIFORM_BUFFER</constant>. <parameter>offset</parameter> and
73 <parameter>length</parameter> indicate the range of data in the buffer object htat is to be mapped, in terms of basic machine units.
74 <parameter>access</parameter> is a bitfield containing flags which describe the requested mapping. These flags are described below.
75 </para>
76 <para>
77 If no error occurs, a pointer to the beginning of the mapped range is returned once all pending operations on that buffer have
78 completed, and may be used to modify and/or query the corresponding range of the buffer, according to the following flag bits set
79 in <parameter>access</parameter>:
80 <itemizedlist>
81 <listitem>
82 <para>
83 <constant>GL_MAP_READ_BIT</constant> indicates that the returned pointer may be used to read
84 buffer object data. No GL error is generated if the pointer is used to query
85 a mapping which excludes this flag, but the result is undefined and system
86 errors (possibly including program termination) may occur.
87 </para>
88 </listitem>
89 <listitem>
90 <para>
91 <constant>GL_MAP_WRITE_BIT</constant> indicates that the returned pointer may be used to modify
92 buffer object data. No GL error is generated if the pointer is used to modify
93 a mapping which excludes this flag, but the result is undefined and system
94 errors (possibly including program termination) may occur.
95 </para>
96 </listitem>
97 </itemizedlist>
98 </para>
99 <para>
100 Furthermore, the following <emphasis>optional</emphasis> flag bits in <parameter>access</parameter> may be used to modify the mapping:
101 <itemizedlist>
102 <listitem>
103 <para>
104 <constant>GL_MAP_INVALIDATE_RANGE_BIT</constant> indicates that the previous contents of the
105 specified range may be discarded. Data within this range are undefined with
106 the exception of subsequently written data. No GL error is generated if sub-
107 sequent GL operations access unwritten data, but the result is undefined and
108 system errors (possibly including program termination) may occur. This flag
109 may not be used in combination with <constant>GL_MAP_READ_BIT</constant>.
110 </para>
111 </listitem>
112 <listitem>
113 <para>
114 <constant>GL_MAP_INVALIDATE_BUFFER_BIT</constant> indicates that the previous contents of the
115 entire buffer may be discarded. Data within the entire buffer are undefined
116 with the exception of subsequently written data. No GL error is generated if
117 subsequent GL operations access unwritten data, but the result is undefined
118 and system errors (possibly including program termination) may occur. This
119 flag may not be used in combination with <constant>GL_MAP_READ_BIT</constant>.
120 </para>
121 </listitem>
122 <listitem>
123 <para>
124 <constant>GL_MAP_FLUSH_EXPLICIT_BIT</constant> indicates that one or more discrete subranges
125 of the mapping may be modified. When this flag is set, modifications to
126 each subrange must be explicitly flushed by calling <citerefentry><refentrytitle>glFlushMappedBufferRange</refentrytitle></citerefentry>.
127 No GL error is set if a subrange of the mapping is modified and
128 not flushed, but data within the corresponding subrange of the buffer are undefined.
129 This flag may only be used in conjunction with <constant>GL_MAP_WRITE_BIT</constant>.
130 When this option is selected, flushing is strictly limited to regions that are
131 explicitly indicated with calls to <citerefentry><refentrytitle>glFlushMappedBufferRange</refentrytitle></citerefentry>
132 prior to unmap; if this option is not selected <citerefentry><refentrytitle>glUnmapBuffer</refentrytitle></citerefentry>
133 will automatically flush the entire mapped range when called.
134 </para>
135 </listitem>
136 <listitem>
137 <para>
138 <constant>GL_MAP_UNSYNCHRONIZED_BIT</constant> indicates that the GL should not attempt to
139 synchronize pending operations on the buffer prior to returning from <function>glMapBufferRange</function>.
140 No GL error is generated if pending operations which source or modify the buffer overlap the mapped region,
141 but the result of such previous and any subsequent operations is undefined.
142 </para>
143 </listitem>
144 </itemizedlist>
145 </para>
146 <para>
147 If an error occurs, <function>glMapBufferRange</function> returns a <code>NULL</code> pointer.
148 </para>
149 </refsect1>
150 <refsect1 id="errors"><title>Errors</title>
151 <para>
152 <constant>GL_INVALID_VALUE</constant> is generated if either of <parameter>offset</parameter> or <parameter>length</parameter> is negative,
153 or if <parameter>offset</parameter> + <parameter>length</parameter> is greater than the value of <constant>GL_BUFFER_SIZE</constant>.
154 </para>
155 <para>
156 <constant>GL_INVALID_VALUE</constant> is generated if <parameter>access</parameter> has any bits set other than those defined above.
157 </para>
158 <para>
159 <constant>GL_INVALID_OPERATION</constant> is generated for any of the following conditions:
160 <itemizedlist>
161 <listitem>
162 <para>
163 The buffer is already in a mapped state.
164 </para>
165 </listitem>
166 <listitem>
167 <para>
168 Neither <constant>GL_MAP_READ_BIT</constant> or <constant>GL_MAP_WRITE_BIT</constant> is set.
169 </para>
170 </listitem>
171 <listitem>
172 <para>
173 <constant>GL_MAP_READ_BIT</constant> is set and any of <constant>GL_MAP_INVALIDATE_RANGE_BIT</constant>,
174 <constant>GL_MAP_INVALIDATE_BUFFER_BIT</constant>, or <constant>GL_MAP_UNSYNCHRONIZED_BIT</constant> is set.
175 </para>
176 </listitem>
177 <listitem>
178 <para>
179 <constant>GL_MAP_FLUSH_EXPLICIT_BIT</constant> is set and <constant>GL_MAP_WRITE_BIT</constant> is not set.
180 </para>
181 </listitem>
182 </itemizedlist>
183 </para>
184 <para>
185 <constant>GL_OUT_OF_MEMORY</constant> is generated if <function>glMapBufferRange</function> fails because memory for the
186 mapping could not be obtained.
187 </para>
188 </refsect1>
189 <refsect1 id="seealso"><title>See Also</title>
190 <para>
191 <citerefentry><refentrytitle>glMapBuffer</refentrytitle></citerefentry>,
192 <citerefentry><refentrytitle>glFlushMappedBufferRange</refentrytitle></citerefentry>,
193 <citerefentry><refentrytitle>glBindBuffer</refentrytitle></citerefentry>
194 </para>
195 </refsect1>
196 <refsect1 id="Copyright"><title>Copyright</title>
197 <para>
198 Copyright <trademark class="copyright"></trademark> 2010 Khronos Group.
199 This material may be distributed subject to the terms and conditions set forth in
200 the Open Publication License, v 1.0, 8 June 1999.
201 <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
202 </para>
203 </refsect1>
204 </refentry>