gluPerspective

set up a perspective projection matrix

Signature

gluPerspective( GLdouble ( fovy ) , GLdouble ( aspect ) , GLdouble ( zNear ) , GLdouble ( zFar ) )-> void
gluPerspective( fovy , aspect , zNear , zFar )
gluPerspective( GLdouble(fovy), GLdouble(aspect), GLdouble(zNear), GLdouble(zFar) ) -> None

Parameters

VariablesDescription
fovy
Specifies the field of view angle, in degrees, in the y direction.
aspect
Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
zNear
Specifies the distance from the viewer to the near clipping plane (always positive).
zFar
Specifies the distance from the viewer to the far clipping plane (always positive).

Description

gluPerspective specifies a viewing frustum into the world coordinate system. In general, the aspect ratio in gluPerspective should match the aspect ratio of the associated viewport. For example, aspect = 2.0 means the viewer's angle of view is twice as wide in x as it is in y . If the viewport is twice as wide as it is tall, it displays the image without distortion.
The matrix generated by gluPerspective is multiplied by the current matrix, just as if glMultMatrix were called with the generated matrix. To load the perspective matrix onto the current matrix stack instead, precede the call to gluPerspective with a call to glLoadIdentity .
Given f defined as follows:
f = cotangent fovy 2
The generated matrix is
f aspect 0 0 0 0 f 0 0 0 0 zFar + zNear zNear - zFar 2 zFar zNear zNear - zFar 0 0 -1 0

Notes

Depth buffer precision is affected by the values specified for zNear and zFar . The greater the ratio of zFar to zNear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If
r = zFar zNear
roughly log 2 r bits of depth buffer precision are lost. Because r approaches infinity as zNear approaches 0, zNear must never be set to 0.

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.

gluPerspective
OpenGLContext OpenGLContext/browser/nodes.py Lines: 32
OpenGLContext OpenGLContext/move/viewplatform.py Lines: 140
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson11.py Lines: 56, 68
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 119, 138
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 95, 107
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 213
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 60, 72
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 75, 87
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson5.py Lines: 73, 85
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson4.py Lines: 70, 82
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 76, 88
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson12.py Lines: 52, 64
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson3.py Lines: 60, 72
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson13.py Lines: 133
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson1.py Lines: 60, 72
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 124, 136
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 277, 285, 293, 361
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson2.py Lines: 60, 72
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 130, 142
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 363
OpenGL-Demo PyOpenGL-Demo/proesch/nurbs/nurbs.py Lines: 146
OpenGL-Demo PyOpenGL-Demo/GLUT/shader_test.py Lines: 34, 75
OpenGL-Demo PyOpenGL-Demo/GLUT/molehill.py Lines: 133
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/checker.py Lines: 63
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/lorentz.py Lines: 72
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/text.py Lines: 56
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 65
OpenGL-Demo PyOpenGL-Demo/redbook/movelight.py Lines: 117
OpenGL-Demo py2exe-example/shader_test.py Lines: 35, 76
{LGPL} PyUI2 renderers/openglGlut.py Lines: 232
{LGPL} PyUI2 system/glutdevice.py Lines: 173
{LGPL} PyMT examples/apps/3Ddrawing/3Ddrawing.py Lines: 39
{LGPL} PyMT examples/apps/3Dviewer/3Dviewer.py Lines: 48
{LGPL} Pyggel pyggel/view.py Lines: 302
{LGPL} Pyggel pyggel/data.py Lines: 551, 613
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 772
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 57, 321
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 41
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 755
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Examples/simplecube/simplecube.py Lines: 40
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Display3D.py Lines: 147
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py Lines: 152, 459
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/Old/SoC/simplecube.py Lines: 69
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube_controlled.py Lines: 92
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube.py Lines: 40
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Display3D.py Lines: 147
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 152, 459
Gloopy gloopy/view/projection.py Lines: 41
Visvis core/cameras.py Lines: 1152, 1767

MathML Rendering

Powered by MathJax