| 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="glBufferSubData"> |
| 5 | <refmeta> |
| 6 | <refmetainfo> |
| 7 | <copyright> |
| 8 | <year>2005</year> |
| 9 | <holder>Sams Publishing</holder> |
| 10 | </copyright> |
| 11 | </refmetainfo> |
| 12 | <refentrytitle>glBufferSubData</refentrytitle> |
| 13 | <manvolnum>3G</manvolnum> |
| 14 | </refmeta> |
| 15 | <refnamediv> |
| 16 | <refname>glBufferSubData</refname> |
| 17 | <refpurpose>updates a subset of a buffer object's data store</refpurpose> |
| 18 | </refnamediv> |
| 19 | <refsynopsisdiv><title>C Specification</title> |
| 20 | <funcsynopsis> |
| 21 | <funcprototype> |
| 22 | <funcdef>void <function>glBufferSubData</function></funcdef> |
| 23 | <paramdef>GLenum <parameter>target</parameter></paramdef> |
| 24 | <paramdef>GLintptr <parameter>offset</parameter></paramdef> |
| 25 | <paramdef>GLsizeiptr <parameter>size</parameter></paramdef> |
| 26 | <paramdef>const GLvoid * <parameter>data</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>offset</parameter></term> |
| 57 | <listitem> |
| 58 | <para> |
| 59 | Specifies the offset into the buffer object's data store where data replacement will begin, |
| 60 | measured in bytes. |
| 61 | </para> |
| 62 | </listitem> |
| 63 | </varlistentry> |
| 64 | <varlistentry> |
| 65 | <term><parameter>size</parameter></term> |
| 66 | <listitem> |
| 67 | <para> |
| 68 | Specifies the size in bytes of the data store region being replaced. |
| 69 | </para> |
| 70 | </listitem> |
| 71 | </varlistentry> |
| 72 | <varlistentry> |
| 73 | <term><parameter>data</parameter></term> |
| 74 | <listitem> |
| 75 | <para> |
| 76 | Specifies a pointer to the new data that will be copied into the data store. |
| 77 | </para> |
| 78 | </listitem> |
| 79 | </varlistentry> |
| 80 | </variablelist> |
| 81 | </refsect1> |
| 82 | <refsect1 id="description"><title>Description</title> |
| 83 | <para> |
| 84 | <function>glBufferSubData</function> redefines some or all of the data store for the buffer object currently |
| 85 | bound to <parameter>target</parameter>. Data starting at byte offset <parameter>offset</parameter> and |
| 86 | extending for <parameter>size</parameter> bytes is copied to the data store from the memory pointed to by |
| 87 | <parameter>data</parameter>. An error is thrown if <parameter>offset</parameter> and <parameter>size</parameter> |
| 88 | together define a range beyond the bounds of the buffer object's data store. |
| 89 | </para> |
| 90 | </refsect1> |
| 91 | <refsect1 id="notes"><title>Notes</title> |
| 92 | <para> |
| 93 | When replacing the entire data store, consider using <function>glBufferSubData</function> rather |
| 94 | than completely recreating the data store with <function>glBufferData</function>. This avoids the cost of |
| 95 | reallocating the data store. |
| 96 | </para> |
| 97 | <para> |
| 98 | Consider using multiple buffer objects to avoid stalling the rendering pipeline during data store updates. |
| 99 | If any rendering in the pipeline makes reference to data in the buffer object being updated by |
| 100 | <function>glBufferSubData</function>, especially from the specific region being updated, that rendering must |
| 101 | drain from the pipeline before the data store can be updated. |
| 102 | </para> |
| 103 | <para> |
| 104 | Clients must align data elements consistent with the requirements of the client |
| 105 | platform, with an additional base-level requirement that an offset within a buffer to |
| 106 | a datum comprising <inlineequation><mml:math><mml:mi mathvariant="italic">N</mml:mi> bytes be a |
| 107 | multiple of <mml:mi mathvariant="italic">N</mml:mi></mml:math></inlineequation>. |
| 108 | </para> |
| 109 | <para> |
| 110 | The <constant>GL_ATOMIC_COUNTER_BUFFER</constant> target is available only if the GL version |
| 111 | is 4.2 or greater. |
| 112 | </para> |
| 113 | <para> |
| 114 | The <constant>GL_DISPATCH_INDIRECT_BUFFER</constant> and <constant>GL_SHADER_STORAGE_BUFFER</constant> targets are available only if the GL version |
| 115 | is 4.3 or greater. |
| 116 | </para> |
| 117 | </refsect1> |
| 118 | <refsect1 id="errors"><title>Errors</title> |
| 119 | <para> |
| 120 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>target</parameter> is not |
| 121 | one of the accepted buffer targets. |
| 122 | </para> |
| 123 | <para> |
| 124 | <constant>GL_INVALID_VALUE</constant> is generated if <parameter>offset</parameter> or |
| 125 | <parameter>size</parameter> is negative, or if together they define a region of memory |
| 126 | that extends beyond the buffer object's allocated data store. |
| 127 | </para> |
| 128 | <para> |
| 129 | <constant>GL_INVALID_OPERATION</constant> is generated if the reserved buffer object name 0 is bound to <parameter>target</parameter>. |
| 130 | </para> |
| 131 | <para> |
| 132 | <constant>GL_INVALID_OPERATION</constant> is generated if the buffer object being updated is mapped. |
| 133 | </para> |
| 134 | </refsect1> |
| 135 | <refsect1 id="associatedgets"><title>Associated Gets</title> |
| 136 | <para> |
| 137 | <citerefentry><refentrytitle>glGetBufferSubData</refentrytitle></citerefentry> |
| 138 | </para> |
| 139 | </refsect1> |
| 140 | <refsect1 id="seealso"><title>See Also</title> |
| 141 | <para> |
| 142 | <citerefentry><refentrytitle>glBindBuffer</refentrytitle></citerefentry>, |
| 143 | <citerefentry><refentrytitle>glBufferData</refentrytitle></citerefentry>, |
| 144 | <citerefentry><refentrytitle>glMapBuffer</refentrytitle></citerefentry>, |
| 145 | <citerefentry><refentrytitle>glUnmapBuffer</refentrytitle></citerefentry> |
| 146 | </para> |
| 147 | </refsect1> |
| 148 | <refsect1 id="Copyright"><title>Copyright</title> |
| 149 | <para> |
| 150 | Copyright <trademark class="copyright"></trademark> 2005 Addison-Wesley. |
| 151 | This material may be distributed subject to the terms and conditions set forth in |
| 152 | the Open Publication License, v 1.0, 8 June 1999. |
| 153 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. |
| 154 | </para> |
| 155 | </refsect1> |
| 156 | </refentry> |