Commit | Line | Data |
---|---|---|
7faf1d71 AW |
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="glBufferData"> | |
5 | <refmeta> | |
6 | <refmetainfo> | |
7 | <copyright> | |
8 | <year>2005</year> | |
9 | <holder>Sams Publishing</holder> | |
10 | </copyright> | |
11 | </refmetainfo> | |
12 | <refentrytitle>glBufferData</refentrytitle> | |
13 | <manvolnum>3G</manvolnum> | |
14 | </refmeta> | |
15 | <refnamediv> | |
16 | <refname>glBufferData</refname> | |
17 | <refpurpose>creates and initializes a buffer object's data store</refpurpose> | |
18 | </refnamediv> | |
19 | <refsynopsisdiv><title>C Specification</title> | |
20 | <funcsynopsis> | |
21 | <funcprototype> | |
22 | <funcdef>void <function>glBufferData</function></funcdef> | |
23 | <paramdef>GLenum <parameter>target</parameter></paramdef> | |
24 | <paramdef>GLsizeiptr <parameter>size</parameter></paramdef> | |
25 | <paramdef>const GLvoid * <parameter>data</parameter></paramdef> | |
26 | <paramdef>GLenum <parameter>usage</parameter></paramdef> | |
27 | </funcprototype> | |
28 | </funcsynopsis> | |
29 | </refsynopsisdiv> | |
30 | <!-- eqn: ignoring delim $$ --> | |
31 | <refsect1 id="parameters"><title>Parameters</title> | |
32 | <variablelist> | |
33 | <varlistentry> | |
34 | <term><parameter>target</parameter></term> | |
35 | <listitem> | |
36 | <para> | |
37 | Specifies the target buffer object. | |
38 | The symbolic constant must be <constant>GL_ARRAY_BUFFER</constant>, | |
39 | <constant>GL_ELEMENT_ARRAY_BUFFER</constant>, | |
40 | <constant>GL_PIXEL_PACK_BUFFER</constant>, or | |
41 | <constant>GL_PIXEL_UNPACK_BUFFER</constant>. | |
42 | </para> | |
43 | </listitem> | |
44 | </varlistentry> | |
45 | <varlistentry> | |
46 | <term><parameter>size</parameter></term> | |
47 | <listitem> | |
48 | <para> | |
49 | Specifies the size in bytes of the buffer object's new data store. | |
50 | </para> | |
51 | </listitem> | |
52 | </varlistentry> | |
53 | <varlistentry> | |
54 | <term><parameter>data</parameter></term> | |
55 | <listitem> | |
56 | <para> | |
57 | Specifies a pointer to data that will be copied into the data store for initialization, | |
58 | or <constant>NULL</constant> if no data is to be copied. | |
59 | </para> | |
60 | </listitem> | |
61 | </varlistentry> | |
62 | <varlistentry> | |
63 | <term><parameter>usage</parameter></term> | |
64 | <listitem> | |
65 | <para> | |
66 | Specifies the expected usage pattern of the data store. The symbolic constant must be | |
67 | <constant>GL_STREAM_DRAW</constant>, <constant>GL_STREAM_READ</constant>, <constant>GL_STREAM_COPY</constant>, | |
68 | <constant>GL_STATIC_DRAW</constant>, <constant>GL_STATIC_READ</constant>, <constant>GL_STATIC_COPY</constant>, | |
69 | <constant>GL_DYNAMIC_DRAW</constant>, <constant>GL_DYNAMIC_READ</constant>, or <constant>GL_DYNAMIC_COPY</constant>. | |
70 | </para> | |
71 | </listitem> | |
72 | </varlistentry> | |
73 | </variablelist> | |
74 | </refsect1> | |
75 | <refsect1 id="description"><title>Description</title> | |
76 | <para> | |
77 | <function>glBufferData</function> creates a new data store for the buffer object currently bound to | |
78 | <parameter>target</parameter>. Any pre-existing data store is deleted. The new data store is created with the | |
79 | specified <parameter>size</parameter> in bytes and <parameter>usage</parameter>. If <parameter>data</parameter> | |
80 | is not <constant>NULL</constant>, the data store is initialized with data from this pointer. In its initial | |
81 | state, the new data store is not mapped, it has a <constant>NULL</constant> mapped pointer, and its mapped access | |
82 | is <constant>GL_READ_WRITE</constant>. | |
83 | </para> | |
84 | <para> | |
85 | <parameter>usage</parameter> is a hint to the GL implementation as to how a buffer object's data store will be | |
86 | accessed. This enables the GL implementation to make more intelligent decisions that may significantly | |
87 | impact buffer object performance. It does not, however, constrain the actual usage of the data store. | |
88 | <parameter>usage</parameter> can be broken down into two parts: first, the frequency of access (modification | |
89 | and usage), and second, the nature of that access. The frequency of access may be one of these: | |
90 | </para> | |
91 | <variablelist> | |
92 | <varlistentry> | |
93 | <term>STREAM</term> | |
94 | <listitem> | |
95 | <para> | |
96 | The data store contents will be modified once and used at most a few times. | |
97 | </para> | |
98 | </listitem> | |
99 | </varlistentry> | |
100 | <varlistentry> | |
101 | <term>STATIC</term> | |
102 | <listitem> | |
103 | <para> | |
104 | The data store contents will be modified once and used many times. | |
105 | </para> | |
106 | </listitem> | |
107 | </varlistentry> | |
108 | <varlistentry> | |
109 | <term>DYNAMIC</term> | |
110 | <listitem> | |
111 | <para> | |
112 | The data store contents will be modified repeatedly and used many times. | |
113 | </para> | |
114 | </listitem> | |
115 | </varlistentry> | |
116 | </variablelist> | |
117 | <para> | |
118 | The nature of access may be one of these: | |
119 | </para> | |
120 | <variablelist> | |
121 | <varlistentry> | |
122 | <term>DRAW</term> | |
123 | <listitem> | |
124 | <para> | |
125 | The data store contents are modified by the application, and used as the source for GL drawing and | |
126 | image specification commands. | |
127 | </para> | |
128 | </listitem> | |
129 | </varlistentry> | |
130 | <varlistentry> | |
131 | <term>READ</term> | |
132 | <listitem> | |
133 | <para> | |
134 | The data store contents are modified by reading data from the GL, and used to return that data | |
135 | when queried by the application. | |
136 | </para> | |
137 | </listitem> | |
138 | </varlistentry> | |
139 | <varlistentry> | |
140 | <term>COPY</term> | |
141 | <listitem> | |
142 | <para> | |
143 | The data store contents are modified by reading data from the GL, and used as the source for GL | |
144 | drawing and image specification commands. | |
145 | </para> | |
146 | </listitem> | |
147 | </varlistentry> | |
148 | </variablelist> | |
149 | </refsect1> | |
150 | <refsect1 id="notes"><title>Notes</title> | |
151 | <para> | |
152 | <function>glBufferData</function> is available only if the GL version is 1.5 or greater. | |
153 | </para> | |
154 | <para> | |
155 | Targets <constant>GL_PIXEL_PACK_BUFFER</constant> and <constant>GL_PIXEL_UNPACK_BUFFER</constant> are available | |
156 | only if the GL version is 2.1 or greater. | |
157 | </para> | |
158 | <para> | |
159 | If <parameter>data</parameter> is <constant>NULL</constant>, a data store of the specified size is still created, | |
160 | but its contents remain uninitialized and thus undefined. | |
161 | </para> | |
162 | <para> | |
163 | Clients must align data elements consistent with the requirements of the client | |
164 | platform, with an additional base-level requirement that an offset within a buffer to | |
165 | a datum comprising <inlineequation><mml:math><mml:mi mathvariant="italic">N</mml:mi> bytes be a | |
166 | multiple of <mml:mi mathvariant="italic">N</mml:mi></mml:math></inlineequation>. | |
167 | </para> | |
168 | </refsect1> | |
169 | <refsect1 id="errors"><title>Errors</title> | |
170 | <para> | |
171 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>target</parameter> is not | |
172 | <constant>GL_ARRAY_BUFFER</constant>, <constant>GL_ELEMENT_ARRAY_BUFFER</constant>, | |
173 | <constant>GL_PIXEL_PACK_BUFFER</constant>, or <constant>GL_PIXEL_UNPACK_BUFFER</constant>. | |
174 | </para> | |
175 | <para> | |
176 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>usage</parameter> is not | |
177 | <constant>GL_STREAM_DRAW</constant>, <constant>GL_STREAM_READ</constant>, <constant>GL_STREAM_COPY</constant>, | |
178 | <constant>GL_STATIC_DRAW</constant>, <constant>GL_STATIC_READ</constant>, <constant>GL_STATIC_COPY</constant>, | |
179 | <constant>GL_DYNAMIC_DRAW</constant>, <constant>GL_DYNAMIC_READ</constant>, or <constant>GL_DYNAMIC_COPY</constant>. | |
180 | </para> | |
181 | <para> | |
182 | <constant>GL_INVALID_VALUE</constant> is generated if <parameter>size</parameter> is negative. | |
183 | </para> | |
184 | <para> | |
185 | <constant>GL_INVALID_OPERATION</constant> is generated if the reserved buffer object name 0 is bound to <parameter>target</parameter>. | |
186 | </para> | |
187 | <para> | |
188 | <constant>GL_OUT_OF_MEMORY</constant> is generated if the GL is unable to create a data store with the specified <parameter>size</parameter>. | |
189 | </para> | |
190 | <para> | |
191 | <constant>GL_INVALID_OPERATION</constant> is generated if <function>glBufferData</function> | |
192 | is executed between the execution of | |
193 | <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry> and the corresponding execution of | |
194 | <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>. | |
195 | </para> | |
196 | </refsect1> | |
197 | <refsect1 id="associatedgets"><title>Associated Gets</title> | |
198 | <para> | |
199 | <citerefentry><refentrytitle>glGetBufferSubData</refentrytitle></citerefentry> | |
200 | </para> | |
201 | <para> | |
202 | <citerefentry><refentrytitle>glGetBufferParameteriv</refentrytitle></citerefentry> with argument <constant>GL_BUFFER_SIZE</constant> or <constant>GL_BUFFER_USAGE</constant> | |
203 | </para> | |
204 | </refsect1> | |
205 | <refsect1 id="seealso"><title>See Also</title> | |
206 | <para> | |
207 | <citerefentry><refentrytitle>glBindBuffer</refentrytitle></citerefentry>, | |
208 | <citerefentry><refentrytitle>glBufferSubData</refentrytitle></citerefentry>, | |
209 | <citerefentry><refentrytitle>glMapBuffer</refentrytitle></citerefentry>, | |
210 | <citerefentry><refentrytitle>glUnmapBuffer</refentrytitle></citerefentry> | |
211 | </para> | |
212 | </refsect1> | |
213 | <refsect1 id="Copyright"><title>Copyright</title> | |
214 | <para> | |
215 | Copyright <trademark class="copyright"></trademark> 2005 Addison-Wesley. | |
216 | This material may be distributed subject to the terms and conditions set forth in | |
217 | the Open Publication License, v 1.0, 8 June 1999. | |
218 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. | |
219 | </para> | |
220 | </refsect1> | |
221 | </refentry> |