<?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="glCopyBufferSubData">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>2010</year>
                <holder>Khronos Group</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glCopyBufferSubData</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glCopyBufferSubData</refname>
        <refpurpose>copy part of the data store of a buffer object to the data store of another buffer object</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glCopyBufferSubData</function></funcdef>
                <paramdef>GLenum <parameter>readtarget</parameter></paramdef>
                <paramdef>GLenum <parameter>writetarget</parameter></paramdef>
                <paramdef>GLintptr <parameter>readoffset</parameter></paramdef>
                <paramdef>GLintptr <parameter>writeoffset</parameter></paramdef>
                <paramdef>GLsizeiptr <parameter>size</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>readtarget</parameter></term>
            <listitem>
                <para>
                    Specifies the target from whose data store data should be read.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>writetarget</parameter></term>
            <listitem>
                <para>
                    Specifies the target to whose data store data should be written.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>readoffset</parameter></term>
            <listitem>
                <para>
                    Specifies the offset, in basic machine units, within the data store of <parameter>readtarget</parameter> from which data should be read.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>writeoffset</parameter></term>
            <listitem>
                <para>
                    Specifies the offset, in basic machine units, within the data store of <parameter>writetarget</parameter> to which data should be written.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>size</parameter></term>
            <listitem>
                <para>
                    Specifies the size, in basic machine units, of the data to be copied from <parameter>readtarget</parameter> to <parameter>writetarget</parameter>.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>glCopyBufferSubData</function> copies part of the data store attached to <parameter>readtarget</parameter> to the
            data store attached to <parameter>writetarget</parameter>. The number of basic machine units indicated by <parameter>size</parameter>
            is copied from the source, at offset <parameter>readoffset</parameter> to the destination at <parameter>writeoffset</parameter>,
            also in basic machine units.
        </para>
        <para>
            <parameter>readtarget</parameter> and <parameter>writetarget</parameter> must be <constant>GL_ARRAY_BUFFER</constant>,
            <constant>GL_COPY_READ_BUFFER</constant>, <constant>GL_COPY_WRITE_BUFFER</constant>, <constant>GL_ELEMENT_ARRAY_BUFFER</constant>,
            <constant>GL_PIXEL_PACK_BUFFER</constant>, <constant>GL_PIXEL_UNPACK_BUFFER</constant>, <constant>GL_TEXTURE_BUFFER</constant>,
            <constant>GL_TRANSFORM_FEEDBACK_BUFFER</constant> or <constant>GL_UNIFORM_BUFFER</constant>. Any of these targets may be used,
            although the targets <constant>GL_COPY_READ_BUFFER</constant> and <constant>GL_COPY_WRITE_BUFFER</constant> are provided
            specifically to allow copies between buffers without disturbing other GL state.
        </para>
        <para>
            <parameter>readoffset</parameter>, <parameter>writeoffset</parameter> and <parameter>size</parameter> must all be greater than or equal to
            zero. Furthermore, <parameter>readoffset</parameter> + <parameter>size</parameter> must not exceeed the size of the buffer
            object bound to <parameter>readtarget</parameter>, and <parameter>readoffset</parameter> + <parameter>size</parameter> must not exceeed the
            size of the buffer bound to <parameter>writetarget</parameter>. If the same buffer object is bound to both <parameter>readtarget</parameter>
            and <parameter>writetarget</parameter>, then the ranges specified by <parameter>readoffset</parameter>, <parameter>writeoffset</parameter>
            and <parameter>size</parameter> must not overlap.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
           <function>glCopyBufferSubData</function> is available only if the GL version is 3.1 or greater.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if any of <parameter>readoffset</parameter>, <parameter>writeoffset</parameter>
            or <parameter>size</parameter> is negative, if <parameter>readoffset</parameter> + <parameter>size</parameter> exceeds the
            size of the buffer object bound to <parameter>readtarget</parameter> or if <parameter>writeoffset</parameter> + <parameter>size</parameter>
            exceeds the size of the buffer object bound to <parameter>writetarget</parameter>.
        </para>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if the same buffer object is bound to both <parameter>readtarget</parameter>
            and <parameter>writetarget</parameter> and the ranges [<parameter>readoffset</parameter>, <parameter>readoffset</parameter> +
            <parameter>size</parameter>) and [<parameter>writeoffset</parameter>, <parameter>writeoffset</parameter> + <parameter>size</parameter>)
            overlap.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if zero is bound to <parameter>readtarget</parameter> or <parameter>writetarget</parameter>.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if the buffer object bound to either <parameter>readtarget</parameter> or <parameter>writetarget</parameter>
            is mapped.
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glGenBuffers</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBindBuffer</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBufferData</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBufferSubData</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGetBufferSubData</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"></trademark> 2010 Khronos Group. 
            This material may be distributed subject to the terms and conditions set forth in 
            the Open Publication License, v 1.0, 8 June 1999.
            <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
        </para>
    </refsect1>
</refentry>
