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