glPushMatrix

push and pop the current matrix stack

Signature

glPopMatrix( ( void ) )-> void
glPopMatrix( )
glPushMatrix( ( void ) )-> void
glPushMatrix( )

Description

There is a stack of matrices for each of the matrix modes. In GL_MODELVIEW mode, the stack depth is at least 32. In the other modes, GL_COLOR , GL_PROJECTION , and GL_TEXTURE , the depth is at least 2. The current matrix in any mode is the matrix on the top of the stack for that mode.
glPushMatrix pushes the current matrix stack down by one, duplicating the current matrix. That is, after a glPushMatrix call, the matrix on top of the stack is identical to the one below it.
glPopMatrix pops the current matrix stack, replacing the current matrix with the one below it on the stack.
Initially, each of the stacks contains one matrix, an identity matrix.
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.

Errors

GL_STACK_OVERFLOW is generated if glPushMatrix is called while the current matrix stack is full.
GL_STACK_UNDERFLOW is generated if glPopMatrix is called while the current matrix stack contains only a single matrix.
GL_INVALID_OPERATION is generated if glPushMatrix or glPopMatrix is executed between the execution of glBegin and the corresponding execution of glEnd .

Associated Gets

glGet with argument GL_MATRIX_MODE
glGet with argument GL_COLOR_MATRIX
glGet with argument GL_MODELVIEW_MATRIX
glGet with argument GL_PROJECTION_MATRIX
glGet with argument GL_TEXTURE_MATRIX
glGet with argument GL_COLOR_MATRIX_STACK_DEPTH
glGet with argument GL_MODELVIEW_STACK_DEPTH
glGet with argument GL_PROJECTION_STACK_DEPTH
glGet with argument GL_TEXTURE_STACK_DEPTH
glGet with argument GL_MAX_MODELVIEW_STACK_DEPTH
glGet with argument GL_MAX_PROJECTION_STACK_DEPTH
glGet with argument GL_MAX_TEXTURE_STACK_DEPTH

See Also

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glPopMatrix
OpenGLContext OpenGLContext/doinchildmatrix.py Lines: 34
OpenGLContext OpenGLContext/shadow/volume.py Lines: 331
OpenGLContext OpenGLContext/passes/rendervisitor.py Lines: 396
OpenGLContext tests/shadow_1.py Lines: 295
OpenGLContext tests/glhistogram.py Lines: 79
OpenGLContext tests/gldrawpixelssynth.py Lines: 64
OpenGLContext tests/redbook_alpha3D.py Lines: 130, 144
OpenGLContext tests/glutbitmapcharacter.py Lines: 31
OpenGLContext tests/redbook_surface.py Lines: 86
OpenGLContext tests/gldrawpixels.py Lines: 84
OpenGLContext tests/redbook_trim.py Lines: 125
OpenGLContext tests/redbook_surface_cb.py Lines: 105
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 178, 202
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 175
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson44/glFont.py Lines: 88, 90
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson43/glFreeType.py Lines: 165, 202, 305
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson48/Lesson48.py Lines: 136, 145
OpenGL-Demo PyOpenGL-Demo/proesch/nurbs/nurbs.py Lines: 158
OpenGL-Demo PyOpenGL-Demo/GLE/texas.py Lines: 53
OpenGL-Demo PyOpenGL-Demo/GLE/helix.py Lines: 24
OpenGL-Demo PyOpenGL-Demo/GLE/cone.py Lines: 28
OpenGL-Demo PyOpenGL-Demo/GLUT/gears.py Lines: 148, 154, 160, 162
OpenGL-Demo PyOpenGL-Demo/GLUT/glutplane.py Lines: 90
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/checker.py Lines: 47
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 29
OpenGL-Demo PyOpenGL-Demo/redbook/scene.py Lines: 92, 98, 103, 105
OpenGL-Demo PyOpenGL-Demo/redbook/movelight.py Lines: 107, 110
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 101
OpenGL-Demo PyOpenGL-Demo/redbook/double.py Lines: 72
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 118
OpenGL-Demo PyOpenGL-Demo/tom/pick.py Lines: 22
OpenGL-Demo PyOpenGL-Demo/tom/conechecker.py Lines: 28, 52
OpenGL-Demo PyOpenGL-Demo/tom/conesave.py Lines: 33
OpenGL-Demo PyOpenGL-Demo/tom/checker.py Lines: 28
OpenGL-Demo PyOpenGL-Demo/tom/fog.py Lines: 63
OpenGL-Demo PyOpenGL-Demo/tom/cone.py Lines: 30
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 249
{Artistic License} PymmLib pymmlib/mmLib/OpenGLDriver.py Lines: 240, 449, 473, 506, 580
{LGPL} PyUI2 renderers/openglBase.py Lines: 240, 327, 329
{LGPL} PyUI2 renderers/openglPygame.py Lines: 195, 197, 321
{LGPL} PyUI2 system/openglgraphics.py Lines: 205, 207, 373
{LGPL} VisionEgg VisionEgg/MoreStimuli.py Lines: 175, 388
{LGPL} VisionEgg VisionEgg/Core.py Lines: 555, 881, 1078
{LGPL} VisionEgg VisionEgg/SphereMap.py Lines: 358, 545, 846, 1172, 1218
{LGPL} VisionEgg VisionEgg/Dots.py Lines: 255, 372
{LGPL} VisionEgg VisionEgg/Gratings.py Lines: 425
{LGPL} VisionEgg VisionEgg/Textures.py Lines: 1509, 1907
{LGPL} VisionEgg VisionEgg/Text.py Lines: 429, 509
{LGPL} PyMT examples/apps/3Ddrawing/3Ddrawing.py Lines: 49, 51, 104, 116
{LGPL} PyMT examples/apps/3Dviewer/3Dviewer.py Lines: 58, 60, 85, 161
{LGPL} PyMT examples/games/untangle/data_viewer.py Lines: 68, 69
{LGPL} PyMT examples/games/tictactoe/tictactoe.py Lines: 104
{LGPL} PyMT pymt/graphx/statement.py Lines: 56, 182
{LGPL} PyMT pymt/lib/squirtle.py Lines: 16, 501
{LGPL} Pyggel pyggel/image.py Lines: 106, 177
{LGPL} Pyggel pyggel/misc.py Lines: 226, 339
{LGPL} Pyggel pyggel/view.py Lines: 324
{LGPL} Pyggel pyggel/camera.py Lines: 28, 65
{LGPL} Pyggel pyggel/scene.py Lines: 202
{LGPL} Pyggel pyggel/geometry.py Lines: 157, 309, 339, 459, 492, 589
{LGPL} Pyggel pyggel/font.py Lines: 328, 532, 963, 1009
{LGPL} Pyggel pyggel/mesh.py Lines: 227, 335, 797
{LGPL} pygl2d pygl2d/display.py Lines: 67, 69, 84
{LGPL} pygl2d pygl2d/image.py Lines: 173
{LGPL} pygl2d pygl2d/draw.py Lines: 151
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/Visualisation/PhysicsGraph3D/Particles3D.py Lines: 552, 598, 637, 649
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 809, 813, 891
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Utils/Particles3D.py Lines: 292, 333, 369, 381
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 336, 339
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 787, 791, 869
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Examples/simplecube/simplecube.py Lines: 103
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Scrollbar3D.py Lines: 266
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Button3D.py Lines: 238
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/SimpleCube.py Lines: 180
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/PygameWrapperPlane.py Lines: 165
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Progress3D.py Lines: 216
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/TexPlane.py Lines: 155
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Object3D.py Lines: 164
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py Lines: 418, 471, 475
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 809, 813, 891
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/Old/SoC/simplecube.py Lines: 140
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube_controlled.py Lines: 164
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube.py Lines: 103
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Scrollbar3D.py Lines: 266
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Button3D.py Lines: 238
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/SimpleCube.py Lines: 180
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/PygameWrapperPlane.py Lines: 165
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Progress3D.py Lines: 216
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/TexPlane.py Lines: 155
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Object3D.py Lines: 164
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 418, 471, 475
Gloopy gloopy/view/render.py Lines: 147
Visvis text/text_freetype.py Lines: 589
Visvis text/text_prerendered.py Lines: 190
Visvis wibjects/colorWibjects.py Lines: 557
Visvis core/base.py Lines: 197
{GPL3} OpenGL-Programmable 05-shader.py Lines: 196
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 215
{GPL3} OpenGL-Programmable 03-array.py Lines: 111
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 204
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 95
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 130
{GPL3} OpenGL-Programmable 01-direct.py Lines: 100
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 226
glPushMatrix
OpenGLContext OpenGLContext/doinchildmatrix.py Lines: 21
OpenGLContext OpenGLContext/shadow/volume.py Lines: 328
OpenGLContext OpenGLContext/passes/rendervisitor.py Lines: 254
OpenGLContext tests/shadow_1.py Lines: 291
OpenGLContext tests/glhistogram.py Lines: 58
OpenGLContext tests/gldrawpixelssynth.py Lines: 52
OpenGLContext tests/redbook_alpha3D.py Lines: 125, 132
OpenGLContext tests/glutbitmapcharacter.py Lines: 20
OpenGLContext tests/redbook_surface.py Lines: 69
OpenGLContext tests/gldrawpixels.py Lines: 72
OpenGLContext tests/redbook_trim.py Lines: 97
OpenGLContext tests/redbook_surface_cb.py Lines: 86
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 148, 182
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 165
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson44/glFont.py Lines: 76, 80
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson43/glFreeType.py Lines: 130, 190, 292
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson48/Lesson48.py Lines: 132, 141
OpenGL-Demo PyOpenGL-Demo/proesch/nurbs/nurbs.py Lines: 149
OpenGL-Demo PyOpenGL-Demo/GLE/texas.py Lines: 45
OpenGL-Demo PyOpenGL-Demo/GLE/helix.py Lines: 17
OpenGL-Demo PyOpenGL-Demo/GLE/cone.py Lines: 19
OpenGL-Demo PyOpenGL-Demo/GLUT/gears.py Lines: 139, 144, 150, 156
OpenGL-Demo PyOpenGL-Demo/GLUT/glutplane.py Lines: 64
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/checker.py Lines: 42
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 23
OpenGL-Demo PyOpenGL-Demo/redbook/scene.py Lines: 86, 88, 94, 100
OpenGL-Demo PyOpenGL-Demo/redbook/movelight.py Lines: 95, 98
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 98
OpenGL-Demo PyOpenGL-Demo/redbook/double.py Lines: 68
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 104
OpenGL-Demo PyOpenGL-Demo/tom/pick.py Lines: 19
OpenGL-Demo PyOpenGL-Demo/tom/conechecker.py Lines: 25, 48
OpenGL-Demo PyOpenGL-Demo/tom/conesave.py Lines: 29
OpenGL-Demo PyOpenGL-Demo/tom/checker.py Lines: 25
OpenGL-Demo PyOpenGL-Demo/tom/fog.py Lines: 56
OpenGL-Demo PyOpenGL-Demo/tom/cone.py Lines: 26
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 229
{Artistic License} PymmLib pymmlib/mmLib/OpenGLDriver.py Lines: 235, 441, 464, 503, 568
{LGPL} PyUI2 renderers/openglBase.py Lines: 225, 308, 313
{LGPL} PyUI2 renderers/openglPygame.py Lines: 185, 189, 315
{LGPL} PyUI2 system/openglgraphics.py Lines: 186, 191, 367
{LGPL} VisionEgg VisionEgg/MoreStimuli.py Lines: 112, 316
{LGPL} VisionEgg VisionEgg/Core.py Lines: 805, 874, 1074
{LGPL} VisionEgg VisionEgg/SphereMap.py Lines: 252, 529, 835, 1071, 1210
{LGPL} VisionEgg VisionEgg/Dots.py Lines: 242, 366
{LGPL} VisionEgg VisionEgg/Gratings.py Lines: 329
{LGPL} VisionEgg VisionEgg/Textures.py Lines: 1448, 1783
{LGPL} VisionEgg VisionEgg/Text.py Lines: 415, 479
{LGPL} PyMT examples/apps/3Ddrawing/3Ddrawing.py Lines: 37, 42, 101, 109
{LGPL} PyMT examples/apps/3Dviewer/3Dviewer.py Lines: 46, 51, 82, 154
{LGPL} PyMT examples/games/untangle/data_viewer.py Lines: 16, 61
{LGPL} PyMT pymt/graphx/statement.py Lines: 54, 55, 176
{LGPL} PyMT pymt/lib/squirtle.py Lines: 15, 489
{LGPL} Pyggel pyggel/image.py Lines: 91, 158
{LGPL} Pyggel pyggel/misc.py Lines: 212, 323
{LGPL} Pyggel pyggel/view.py Lines: 310
{LGPL} Pyggel pyggel/camera.py Lines: 24, 57, 100
{LGPL} Pyggel pyggel/scene.py Lines: 191
{LGPL} Pyggel pyggel/geometry.py Lines: 138, 293, 336, 443, 489, 572
{LGPL} Pyggel pyggel/font.py Lines: 310, 517, 950, 991
{LGPL} Pyggel pyggel/mesh.py Lines: 208, 300, 757
{LGPL} pygl2d pygl2d/display.py Lines: 58, 62, 80
{LGPL} pygl2d pygl2d/image.py Lines: 167
{LGPL} pygl2d pygl2d/draw.py Lines: 148
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/Visualisation/PhysicsGraph3D/Particles3D.py Lines: 545, 591, 620, 642
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 788, 802, 883
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Utils/Particles3D.py Lines: 285, 326, 350, 374
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 318, 328
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 771, 780, 861
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Examples/simplecube/simplecube.py Lines: 60
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Scrollbar3D.py Lines: 164
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Button3D.py Lines: 180
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/SimpleCube.py Lines: 138
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/PygameWrapperPlane.py Lines: 148
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Progress3D.py Lines: 139
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/TexPlane.py Lines: 140
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Object3D.py Lines: 122
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py Lines: 412, 456, 464
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 788, 802, 883
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/Old/SoC/simplecube.py Lines: 97
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube_controlled.py Lines: 120
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube.py Lines: 60
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Scrollbar3D.py Lines: 164
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Button3D.py Lines: 180
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/SimpleCube.py Lines: 138
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/PygameWrapperPlane.py Lines: 148
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Progress3D.py Lines: 139
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/TexPlane.py Lines: 140
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Object3D.py Lines: 122
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 412, 456, 464
Gloopy gloopy/view/render.py Lines: 128
Visvis text/text_freetype.py Lines: 579
Visvis text/text_prerendered.py Lines: 181
Visvis wibjects/colorWibjects.py Lines: 527
Visvis core/base.py Lines: 169
{GPL3} OpenGL-Programmable 05-shader.py Lines: 185
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 204
{GPL3} OpenGL-Programmable 03-array.py Lines: 100
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 193
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 89
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 119
{GPL3} OpenGL-Programmable 01-direct.py Lines: 84
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 215