<?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="glPushMatrix">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glPushMatrix</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glPushMatrix</refname>
        <refpurpose>push and pop the current matrix stack</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glPushMatrix</function></funcdef>
                <paramdef> <parameter>void</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>glPopMatrix</function></funcdef>
                <paramdef> <parameter>void</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 id="description"><title>Description</title>
        <para>
            There is a stack of matrices for each of the matrix modes.
            In <constant>GL_MODELVIEW</constant> mode,
            the stack depth is at least 32.
            In the other modes,
            <constant>GL_COLOR</constant>, <constant>GL_PROJECTION</constant>, and <constant>GL_TEXTURE</constant>,
            the depth is at least 2.
            The current matrix in any mode is the matrix on the top of the stack
            for that mode.
        </para>
        <para>
            <function>glPushMatrix</function> pushes the current matrix stack down by one,
            duplicating the current matrix.
            That is,
            after a <function>glPushMatrix</function> call,
            the matrix on top of the stack is identical to the one below it.
        </para>
        <para>
            <citerefentry><refentrytitle>glPopMatrix</refentrytitle></citerefentry> pops the current matrix stack,
            replacing the current matrix with the one below it on the stack.
        </para>
        <para>
            Initially, each of the stacks contains one matrix, an identity matrix.
        </para>
        <para>
            It is an error to push a full matrix stack
            or to pop a matrix stack that contains only a single matrix.
            In either case, the error flag is set
            and no other change is made to GL state.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_STACK_OVERFLOW</constant> is generated if <function>glPushMatrix</function> is called while
            the current matrix stack is full.
        </para>
        <para>
            <constant>GL_STACK_UNDERFLOW</constant> is generated if <citerefentry><refentrytitle>glPopMatrix</refentrytitle></citerefentry> is called while
            the current matrix stack contains only a single matrix.
        </para>
        <para>
            <constant>GL_INVALID_OPERATION</constant> is generated if <function>glPushMatrix</function> or <citerefentry><refentrytitle>glPopMatrix</refentrytitle></citerefentry>
            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>glGet</refentrytitle></citerefentry> with argument <constant>GL_MATRIX_MODE</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_COLOR_MATRIX</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MODELVIEW_MATRIX</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_PROJECTION_MATRIX</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_MATRIX</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_COLOR_MATRIX_STACK_DEPTH</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MODELVIEW_STACK_DEPTH</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_PROJECTION_STACK_DEPTH</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_STACK_DEPTH</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MAX_MODELVIEW_STACK_DEPTH</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MAX_PROJECTION_STACK_DEPTH</constant>
        </para>
        <para>
            <citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MAX_TEXTURE_STACK_DEPTH</constant>
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glFrustum</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glLoadIdentity</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glLoadMatrix</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glLoadTransposeMatrix</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glMultMatrix</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glMultTransposeMatrix</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glOrtho</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glRotate</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glScale</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glTranslate</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glViewport</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>
