# glOrtho

multiply the current matrix with an orthographic matrix

## Signature

glOrtho( GLdouble ( left ) , GLdouble ( right ) , GLdouble ( bottom ) , GLdouble ( top ) , GLdouble ( nearVal ) , GLdouble ( farVal ) )-> void
glOrtho( left , top , )

## Parameters

VariablesDescription
left, right
Specify the coordinates for the left and right vertical clipping planes.
bottom, top
Specify the coordinates for the bottom and top horizontal clipping planes.
nearVal, farVal
Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer.

## Description

glOrtho describes a transformation that produces a parallel projection. The current matrix (see glMatrixMode ) is multiplied by this matrix and the result replaces the current matrix, as if glMultMatrix were called with the following matrix as its argument:
$\left(\begin{array}{cccc}\frac{2}{\mathit{right}-\mathit{left}}& 0& 0& {\mathit{t}}_{\mathit{x}}\\ 0& \frac{2}{\mathit{top}-\mathit{bottom}}& 0& {\mathit{t}}_{\mathit{y}}\\ 0& 0& \frac{-2}{\mathit{farVal}-\mathit{nearVal}}& {\mathit{t}}_{\mathit{z}}\\ 0& 0& 0& 1\end{array}\right)$
where
${\mathit{t}}_{\mathit{x}}=-\frac{\mathit{right}+\mathit{left}}{\mathit{right}-\mathit{left}}$
${\mathit{t}}_{\mathit{y}}=-\frac{\mathit{top}+\mathit{bottom}}{\mathit{top}-\mathit{bottom}}$
${\mathit{t}}_{\mathit{z}}=-\frac{\mathit{farVal}+\mathit{nearVal}}{\mathit{farVal}-\mathit{nearVal}}$
Typically, the matrix mode is GL_PROJECTION , and $\left(\mathit{left},\mathit{bottom},-\mathit{nearVal}\right)$ and $\left(\mathit{right},\mathit{top},-\mathit{nearVal}\right)$ specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively, assuming that the eye is located at (0, 0, 0). $-\mathit{farVal}$ specifies the location of the far clipping plane. Both nearVal and farVal can be either positive or negative.
Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.

## Errors

GL_INVALID_VALUE is generated if left = right , or bottom = top , or near = far .
GL_INVALID_OPERATION is generated if glOrtho 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

## 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.

glOrtho
OpenGLContext tests/gldrawpixelssynth.py Lines: 51
OpenGLContext tests/glhistogram.py Lines: 58
OpenGLContext tests/gldrawpixels.py Lines: 71
OpenGLContext tests/glutbitmapcharacter.py Lines: 20
OpenGLContext OpenGLContext/framecounter.py Lines: 63
OpenGL-Demo PyOpenGL-Demo/redbook/double.py Lines: 92
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 120, 122
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 185, 187
OpenGL-Demo PyOpenGL-Demo/redbook/hello.py Lines: 84
OpenGL-Demo PyOpenGL-Demo/redbook/drawf.py Lines: 94
OpenGL-Demo PyOpenGL-Demo/redbook/scene.py Lines: 112, 115
OpenGL-Demo PyOpenGL-Demo/da/dots.py Lines: 90
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/arraytest.py Lines: 62
OpenGL-Demo PyOpenGL-Demo/tom/Line.py Lines: 13
OpenGL-Demo PyOpenGL-Demo/tom/arraytest.py Lines: 30
OpenGL-Demo PyOpenGL-Demo/tom/poly.py Lines: 43
Glinter Widget.py Lines: 56
{Artistic License} PymmLib applications/glutviewer.py Lines: 173
{Artistic License} PymmLib mmLib/OpenGLDriver.py Lines: 146
{LGPL} PyUI pyui/renderers/openglPygame.py Lines: 184
{LGPL} PyUI pyui/renderers/openglBase.py Lines: 310
{LGPL} PyUI2 system/openglgraphics.py Lines: 188
{LGPL} PyUI2 renderers/openglPygame.py Lines: 187
{LGPL} PyUI2 renderers/openglBase.py Lines: 310
{LGPL} Pyggel pyggel/view.py Lines: 283
{LGPL} pygl2d pygl2d/window.py Lines: 72
{GPL} Scocca scocca/graphics/opengl/projections.py Lines: 33
Visvis core/cameras.py Lines: 75
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 243
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 232
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 265
{GPL3} OpenGL-Programmable 01-direct.py Lines: 128
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 137
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 158
{GPL3} OpenGL-Programmable 03-array.py Lines: 139
{GPL3} OpenGL-Programmable 05-shader.py Lines: 224