<?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="glUniformBlockBinding">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>2010-2013</year>
                <holder>Khronos Group</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glUniformBlockBinding</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glUniformBlockBinding</refname>
        <refpurpose>assign a binding point to an active uniform block</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glUniformBlockBinding</function></funcdef>
                <paramdef>GLuint <parameter>program</parameter></paramdef>
                <paramdef>GLuint <parameter>uniformBlockIndex</parameter></paramdef>
                <paramdef>GLuint <parameter>uniformBlockBinding</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>program</parameter></term>
            <listitem>
                <para>
                    The name of a program object containing the active uniform block whose binding to assign.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>uniformBlockIndex</parameter></term>
            <listitem>
                <para>
                    The index of the active uniform block within <parameter>program</parameter> whose binding to assign.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>uniformBlockBinding</parameter></term>
            <listitem>
                <para>
                    Specifies the binding point to which to bind the uniform block with index <parameter>uniformBlockIndex</parameter> within <parameter>program</parameter>.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            Binding points for active uniform blocks are assigned using <function>glUniformBlockBinding</function>. Each of a program's active uniform
            blocks has a corresponding uniform buffer binding point. <parameter>program</parameter> is the name of a program object for which the command
            <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry> has been issued in the past.
        </para>
        <para>
            If successful, <function>glUniformBlockBinding</function> specifies that <parameter>program</parameter> will use the data store of the
            buffer object bound to the binding point <parameter>uniformBlockBinding</parameter> to extract the values of the uniforms in the
            uniform block identified by <parameter>uniformBlockIndex</parameter>.
        </para>
        <para>
            When a program object is linked or re-linked, the uniform buffer object binding point assigned to each of its active uniform blocks is reset to zero.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if <parameter>uniformBlockIndex</parameter> is not an active uniform block index of <parameter>program</parameter>.
        </para>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if <parameter>uniformBlockBinding</parameter> is greater than or equal to the value of <constant>GL_MAX_UNIFORM_BUFFER_BINDINGS</constant>.
        </para>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if <parameter>program</parameter> is not the name of a program object generated by the GL.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            <function>glUniformBlockBinding</function> is available only if the GL version is 3.1 or greater.
        </para>
    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
        <para>
            <citerefentry><refentrytitle>glGetActiveUniformBlock</refentrytitle></citerefentry> with argument <constant>GL_UNIFORM_BLOCK_BINDING</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBindBufferBase</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glBindBufferRange</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGetActiveUniformBlock</refentrytitle></citerefentry>
        </para>
    </refsect1>

    <refsect1 id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"></trademark> 2010-2013 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>
