
<refentry id="glConvolutionFilter1D">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glConvolutionFilter1D</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glConvolutionFilter1D</refname>
        <refpurpose>define a one-dimensional convolution filter</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glConvolutionFilter1D</function></funcdef>
                <paramdef>GLenum <parameter>target</parameter></paramdef>
                <paramdef>GLenum <parameter>internalformat</parameter></paramdef>
                <paramdef>GLsizei <parameter>width</parameter></paramdef>
                <paramdef>GLenum <parameter>format</parameter></paramdef>
                <paramdef>GLenum <parameter>type</parameter></paramdef>
                <paramdef>const GLvoid * <parameter>data</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>target</parameter></term>
            <listitem>
                <para>
                    Must be <constant>GL_CONVOLUTION_1D</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>internalformat</parameter></term>
            <listitem>
                <para>
                    The internal format of the convolution filter kernel.
                    The allowable values are
                    <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>width</parameter></term>
            <listitem>
                <para>
                    The width of the pixel array referenced by <parameter>data</parameter>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>format</parameter></term>
            <listitem>
                <para>
                    The format of the pixel data in <parameter>data</parameter>.
                    The allowable values are
                    <constant>GL_ALPHA</constant>,
                    <constant>GL_LUMINANCE</constant>,
                    <constant>GL_LUMINANCE_ALPHA</constant>,
                    <constant>GL_INTENSITY</constant>,
                    <constant>GL_RGB</constant>, and
                    <constant>GL_RGBA</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>type</parameter></term>
            <listitem>
                <para>
                    The type of the pixel data in <parameter>data</parameter>.
                    Symbolic constants
                    <constant>GL_UNSIGNED_BYTE</constant>,
                    <constant>GL_BYTE</constant>,
                    <constant>GL_BITMAP</constant>,
                    <constant>GL_UNSIGNED_SHORT</constant>,
                    <constant>GL_SHORT</constant>,
                    <constant>GL_UNSIGNED_INT</constant>,
                    <constant>GL_INT</constant>,
                    <constant>GL_FLOAT</constant>,
                    <constant>GL_UNSIGNED_BYTE_3_3_2</constant>,
                    <constant>GL_UNSIGNED_BYTE_2_3_3_REV</constant>,
                    <constant>GL_UNSIGNED_SHORT_5_6_5</constant>,
                    <constant>GL_UNSIGNED_SHORT_5_6_5_REV</constant>,
                    <constant>GL_UNSIGNED_SHORT_4_4_4_4</constant>,
                    <constant>GL_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
                    <constant>GL_UNSIGNED_SHORT_5_5_5_1</constant>,
                    <constant>GL_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
                    <constant>GL_UNSIGNED_INT_8_8_8_8</constant>,
                    <constant>GL_UNSIGNED_INT_8_8_8_8_REV</constant>,
                    <constant>GL_UNSIGNED_INT_10_10_10_2</constant>, and
                    <constant>GL_UNSIGNED_INT_2_10_10_10_REV</constant>
                    are accepted.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>data</parameter></term>
            <listitem>
                <para>
                    Pointer to a one-dimensional array of pixel data that is processed to
                    build the convolution filter kernel.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>glConvolutionFilter1D</function> builds a one-dimensional convolution filter kernel from an array of
            pixels.
        </para>
        <para>
            The pixel array specified by <parameter>width</parameter>, <parameter>format</parameter>, <parameter>type</parameter>, and <parameter>data</parameter>
            is extracted from memory and
            processed just as if <citerefentry><refentrytitle>glDrawPixels</refentrytitle></citerefentry> were called, but processing
            stops after the final expansion to RGBA is completed.
        </para>
        <para>
            If a non-zero named buffer object is bound to the <constant>GL_PIXEL_UNPACK_BUFFER</constant> target 
            (see <citerefentry><refentrytitle>glBindBuffer</refentrytitle></citerefentry>) while a convolution filter is
            specified, <parameter>data</parameter> is treated as a byte offset into the buffer object's data store.
        </para>
        <para>
            The R, G, B, and A components of each pixel are next scaled by the four
            1D <constant>GL_CONVOLUTION_FILTER_SCALE</constant> parameters and biased by the
            four 1D <constant>GL_CONVOLUTION_FILTER_BIAS</constant> parameters.
            (The scale and bias parameters are set by <citerefentry><refentrytitle>glConvolutionParameter</refentrytitle></citerefentry>
            using the <constant>GL_CONVOLUTION_1D</constant> target and the names
            <constant>GL_CONVOLUTION_FILTER_SCALE</constant> and <constant>GL_CONVOLUTION_FILTER_BIAS</constant>.
            The parameters themselves are vectors of four values that are applied to red,
            green, blue, and alpha, in that order.)
            The R, G, B, and A values are not clamped to [0,1] at any time during this
            process.
        </para>
        <para>
            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.7*" align="center"/>
                <colspec colwidth="1.7*" 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>
            The red, green, blue, alpha, luminance, and/or intensity components of
            the resulting pixels are stored in floating-point rather than integer
            format.
            They form a one-dimensional filter kernel image indexed with coordinate
            <emphasis>i</emphasis> such that <emphasis>i</emphasis> starts at 0 and increases from left to right.
            Kernel location <emphasis>i</emphasis> is derived from the <emphasis>i</emphasis>th pixel, counting from 0.
        </para>
        <para>
            Note that after a convolution is performed, the resulting color
            components are also scaled by their corresponding
            <constant>GL_POST_CONVOLUTION_c_SCALE</constant> parameters and biased by their
            corresponding <constant>GL_POST_CONVOLUTION_c_BIAS</constant> parameters (where
            <emphasis>c</emphasis> takes on the values <emphasis role="bold">RED</emphasis>, <emphasis role="bold">GREEN</emphasis>, <emphasis role="bold">BLUE</emphasis>, and
            <emphasis role="bold">ALPHA</emphasis>).
            These parameters are set by <citerefentry><refentrytitle>glPixelTransfer</refentrytitle></citerefentry>.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            <function>glConvolutionFilter1D</function> is present only if <code>ARB_imaging</code> is returned when <citerefentry><refentrytitle>glGetString</refentrytitle></citerefentry>
            is called with an argument of <constant>GL_EXTENSIONS</constant>.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter>target</parameter> is not
            <constant>GL_CONVOLUTION_1D</constant>.
        </para>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter>internalformat</parameter> is not one of the
            allowable values.
        </para>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter>format</parameter> is not one of the allowable
            values.
        </para>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter>type</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 or greater
            than the maximum supported value.
            This value may be queried with <citerefentry><refentrytitle>glGetConvolutionParameter</refentrytitle></citerefentry>
            using target <constant>GL_CONVOLUTION_1D</constant> and name
            <constant>GL_MAX_CONVOLUTION_WIDTH</constant>.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>format</parameter> is one of
            <constant>GL_UNSIGNED_BYTE_3_3_2</constant>,
            <constant>GL_UNSIGNED_BYTE_2_3_3_REV</constant>,
            <constant>GL_UNSIGNED_SHORT_5_6_5</constant>, or
            <constant>GL_UNSIGNED_SHORT_5_6_5_REV</constant>
            and <parameter>type</parameter> is not <constant>GL_RGB</constant>.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>format</parameter> is one of
            <constant>GL_UNSIGNED_SHORT_4_4_4_4</constant>,
            <constant>GL_UNSIGNED_SHORT_4_4_4_4_REV</constant>,
            <constant>GL_UNSIGNED_SHORT_5_5_5_1</constant>,
            <constant>GL_UNSIGNED_SHORT_1_5_5_5_REV</constant>,
            <constant>GL_UNSIGNED_INT_8_8_8_8</constant>,
            <constant>GL_UNSIGNED_INT_8_8_8_8_REV</constant>,
            <constant>GL_UNSIGNED_INT_10_10_10_2</constant>, or
            <constant>GL_UNSIGNED_INT_2_10_10_10_REV</constant>
            and <parameter>type</parameter> is neither <constant>GL_RGBA</constant> nor <constant>GL_BGRA</constant>.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to the
            <constant>GL_PIXEL_UNPACK_BUFFER</constant> target and the buffer object's data store is currently mapped.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to the
            <constant>GL_PIXEL_UNPACK_BUFFER</constant> target and the data would be unpacked from the buffer 
            object such that the memory reads required would exceed the data store size.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to the
            <constant>GL_PIXEL_UNPACK_BUFFER</constant> target and <parameter>data</parameter> is not evenly divisible 
            into the number of bytes needed to store in memory a datum indicated by <parameter>type</parameter>.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function>glConvolutionFilter1D</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>glGetConvolutionParameter</refentrytitle></citerefentry>, <citerefentry><refentrytitle>glGetConvolutionFilter</refentrytitle></citerefentry>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_PIXEL_UNPACK_BUFFER_BINDING</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glConvolutionFilter2D</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glSeparableFilter2D</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glConvolutionParameter</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glPixelTransfer</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>
