
<refentry id="glCopyColorTable">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glCopyColorTable</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glCopyColorTable</refname>
        <refpurpose>copy pixels into a color table</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glCopyColorTable</function></funcdef>
                <paramdef>GLenum <parameter>target</parameter></paramdef>
                <paramdef>GLenum <parameter>internalformat</parameter></paramdef>
                <paramdef>GLint <parameter>x</parameter></paramdef>
                <paramdef>GLint <parameter>y</parameter></paramdef>
                <paramdef>GLsizei <parameter>width</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>target</parameter></term>
            <listitem>
                <para>
                    The color table target. Must be
                    <constant>GL_COLOR_TABLE</constant>,
                    <constant>GL_POST_CONVOLUTION_COLOR_TABLE</constant>,
                    or <constant>GL_POST_COLOR_MATRIX_COLOR_TABLE</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>internalformat</parameter></term>
            <listitem>
                <para>
                    The internal storage format of the texture image.
                    Must be one of the following symbolic constants:
                    <constant>GL_ALPHA</constant>,
                    <constant>GL_ALPHA4</constant>,
                    <constant>GL_ALPHA8</constant>,
                    <constant>GL_ALPHA12</constant>,
                    <constant>GL_ALPHA16</constant>,
                    <constant>GL_LUMINANCE</constant>,
                    <constant>GL_LUMINANCE4</constant>,
                    <constant>GL_LUMINANCE8</constant>,
                    <constant>GL_LUMINANCE12</constant>,
                    <constant>GL_LUMINANCE16</constant>,
                    <constant>GL_LUMINANCE_ALPHA</constant>,
                    <constant>GL_LUMINANCE4_ALPHA4</constant>,
                    <constant>GL_LUMINANCE6_ALPHA2</constant>,
                    <constant>GL_LUMINANCE8_ALPHA8</constant>,
                    <constant>GL_LUMINANCE12_ALPHA4</constant>,
                    <constant>GL_LUMINANCE12_ALPHA12</constant>,
                    <constant>GL_LUMINANCE16_ALPHA16</constant>,
                    <constant>GL_INTENSITY</constant>,
                    <constant>GL_INTENSITY4</constant>,
                    <constant>GL_INTENSITY8</constant>,
                    <constant>GL_INTENSITY12</constant>,
                    <constant>GL_INTENSITY16</constant>,
                    <constant>GL_R3_G3_B2</constant>,
                    <constant>GL_RGB</constant>,
                    <constant>GL_RGB4</constant>,
                    <constant>GL_RGB5</constant>,
                    <constant>GL_RGB8</constant>,
                    <constant>GL_RGB10</constant>,
                    <constant>GL_RGB12</constant>,
                    <constant>GL_RGB16</constant>,
                    <constant>GL_RGBA</constant>,
                    <constant>GL_RGBA2</constant>,
                    <constant>GL_RGBA4</constant>,
                    <constant>GL_RGB5_A1</constant>,
                    <constant>GL_RGBA8</constant>,
                    <constant>GL_RGB10_A2</constant>,
                    <constant>GL_RGBA12</constant>, or
                    <constant>GL_RGBA16</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>x</parameter></term>
            <listitem>
                <para>
                    The x coordinate of the lower-left corner of the pixel rectangle
                    to be transferred to the color table.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>y</parameter></term>
            <listitem>
                <para>
                    The y coordinate of the lower-left corner of the pixel rectangle
                    to be transferred to the color table.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>width</parameter></term>
            <listitem>
                <para>
                    The width of the pixel rectangle.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>glCopyColorTable</function> loads a color table with pixels from the current
            <constant>GL_READ_BUFFER</constant> (rather than from main memory, as is the case for
            <citerefentry><refentrytitle>glColorTable</refentrytitle></citerefentry>).
        </para>
        <para>
            The screen-aligned pixel rectangle with lower-left corner at (<parameter>x</parameter>,\ <parameter>y</parameter>)
            having width <parameter>width</parameter> and height 1
            is loaded into the color table. If any pixels within
            this region are outside the window that is associated with the GL
            context, the values obtained for those pixels are undefined.
        </para>
        <para>
            The pixels in the rectangle are processed just as if
            <citerefentry><refentrytitle>glReadPixels</refentrytitle></citerefentry> were called, with <parameter>internalformat</parameter> set to RGBA,
            but processing stops after the final conversion to RGBA.
        </para>
        <para>
            The four scale parameters and the four bias parameters that are defined
            for the table are then used to scale and bias the R, G, B, and A components
            of each pixel. The scale and bias parameters are set by calling
            <citerefentry><refentrytitle>glColorTableParameter</refentrytitle></citerefentry>.
        </para>
        <para>
            Next, the R, G, B, and A values are clamped to the range 
            <inlineequation><mml:math>
                <!-- eqn: [0,1]:-->
                <mml:mfenced open="[" close="]">
                    <mml:mn>0</mml:mn>
                    <mml:mn>1</mml:mn>
                </mml:mfenced>
            </mml:math></inlineequation>.
            Each pixel is then converted to the internal format specified by
            <parameter>internalformat</parameter>. This conversion simply maps the component values of the pixel (R, G, B,
            and A) to the values included in the internal format (red, green, blue,
            alpha, luminance, and intensity).  The mapping is as follows:
        </para>
        <para>
        </para>
        <informaltable frame="topbot">
            <tgroup cols="7" align="left">
                <colspec colwidth="3*" />
                <colspec colwidth="1*" align="center"/>
                <colspec colwidth="1*" align="center"/>
                <colspec colwidth="1*" align="center"/>
                <colspec colwidth="1*" align="center"/>
                <colspec colwidth="1.5*" align="center"/>
                <colspec colwidth="1.5*" align="center"/>
                <thead>
                    <row>
                        <entry rowsep="1" align="left"><emphasis role="bold">
                        Internal Format
                        </emphasis></entry>
                        <entry rowsep="1" align="center"><emphasis role="bold">
                        Red
                        </emphasis></entry>
                        <entry rowsep="1" align="center"><emphasis role="bold">
                        Green
                        </emphasis></entry>
                        <entry rowsep="1" align="center"><emphasis role="bold">
                        Blue
                        </emphasis></entry>
                        <entry rowsep="1" align="center"><emphasis role="bold">
                        Alpha
                        </emphasis></entry>
                        <entry rowsep="1" align="center"><emphasis role="bold">
                        Luminance
                        </emphasis></entry>
                        <entry rowsep="1" align="center"><emphasis role="bold">
                        Intensity
                        </emphasis></entry>
                    </row>
                </thead>
                <tbody>
                    <row>
                        <entry align="left">
                        <constant>GL_ALPHA</constant>
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        A
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                         
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_LUMINANCE</constant>
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        R
                        </entry>
                        <entry align="center">
                         
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_LUMINANCE_ALPHA</constant>
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        A
                        </entry>
                        <entry align="center">
                        R
                        </entry>
                        <entry align="center">
                         
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_INTENSITY</constant>
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        R
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_RGB</constant>
                        </entry>
                        <entry align="center">
                        R
                        </entry>
                        <entry align="center">
                        G
                        </entry>
                        <entry align="center">
                        B
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                         
                        </entry>
                    </row>
                    <row>
                        <entry align="left">
                        <constant>GL_RGBA</constant>
                        </entry>
                        <entry align="center">
                        R
                        </entry>
                        <entry align="center">
                        G
                        </entry>
                        <entry align="center">
                        B
                        </entry>
                        <entry align="center">
                        A
                        </entry>
                        <entry align="center">
                        </entry>
                        <entry align="center">
                         
                        </entry>
                    </row>
                </tbody>
            </tgroup>
        </informaltable>
        <para>
            Finally, the red, green, blue, alpha, luminance, and/or intensity components of
            the resulting pixels are stored in the color table.
            They form a one-dimensional table with indices in the range
            <inlineequation><mml:math>
                <!-- eqn: [0, width-1]:-->
                <mml:mfenced open="[" close="]">
                    <mml:mn>0</mml:mn>
                    <mml:mrow>
                        <mml:mi mathvariant="italic">width</mml:mi>
                        <mml:mo>-</mml:mo>
                        <mml:mn>1</mml:mn>
                    </mml:mrow>
                </mml:mfenced>
            </mml:math></inlineequation>.
        </para>
        <para>
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            <function>glCopyColorTable</function> is available only if <code>ARB_imaging</code> is returned from calling
            <citerefentry><refentrytitle>glGetString</refentrytitle></citerefentry> with an argument of <constant>GL_EXTENSIONS</constant>.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated when <parameter>target</parameter> is not one of the
            allowable values.
        </para>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if <parameter>width</parameter> is less than zero.
        </para>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if <parameter>internalformat</parameter> is not one of the
            allowable values.
        </para>
        <para>
            <constant>GL_TABLE_TOO_LARGE</constant> is generated if the requested color table
            is too large to be supported by the implementation.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function>glCopyColorTable</function> is executed
            between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry> and the corresponding
            execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
        <para>
            <citerefentry><refentrytitle>glGetColorTable</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGetColorTableParameter</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glColorTable</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glColorTableParameter</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glReadPixels</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"></trademark> 1991-2006
            Silicon Graphics, Inc. This document is licensed under the SGI
            Free Software B License. For details, see
            <ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>.
        </para>
    </refsect1>
</refentry>
