<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "DTD/docbook/docbookx.dtd">
<!--
License Applicability. Except to the extent portions of this file are
made subject to an alternative license as permitted in the SGI Free
Software License B, Version 1.1 (the "License"), the contents of this
file are subject only to the provisions of the License. You may not use
this file except in compliance with the License. You may obtain a copy
of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
http://oss.sgi.com/projects/FreeB
Note that, as provided in the License, the Software is distributed on an
"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
Original Code. The Original Code is: OpenGL ES Reference Manual,
Version 1.0, released September 2003, developed by Silicon Graphics,
Inc. The Original Code is Copyright (c) 2003 Silicon Graphics, Inc.
Copyright in any portions created by third parties is as indicated
elsewhere herein. All Rights Reserved.
-->
<refentry id="glPushMatrix">
<refmeta>
<refentrytitle>glPushMatrix</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refname>glPushMatrix</refname>
<refname>glPopMatrix</refname>
<refpurpose>push and pop the current matrix stack</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glPushMatrix</function></funcdef>
<void/>
</funcprototype>
<funcprototype>
<funcdef>void <function>glPopMatrix</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<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 16. In the other modes,
<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><function>glPopMatrix</function>
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>
<title>Notes</title>
<para>
Each texture unit has its own texture matrix stack. Use
<citerefentry><refentrytitle>glActiveTexture</refentrytitle></citerefentry>
to select the desired texture matrix stack.
</para>
</refsect1>
<refsect1>
<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
<function>glPopMatrix</function>
is called while the current matrix stack contains only a single
matrix.</para>
</refsect1>
<refsect1>
<title>Associated Gets</title>
<para>
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>
with argument <constant>GL_MAX_MODELVIEW_STACK_DEPTH</constant>
</para>
<para>
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>
with argument <constant>GL_MAX_PROJECTION_STACK_DEPTH</constant>
</para>
<para>
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>
with argument <constant>GL_MAX_TEXTURE_STACK_DEPTH</constant>
</para>
<para>
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>
with argument <constant>GL_MAX_TEXTURE_UNITS</constant>
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>glActiveTexture</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glFrustum</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glLoadIdentity</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glLoadMatrix</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMultMatrix</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>
</refentry>