<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:mml="http://www.w3.org/1998/Math/MathML"
><head><title>gluPerspective</title><link rel="stylesheet" href="style.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"/><link rel="home" href="index.xml" title="PyOpenGL 2.0.1.07 Man Pages"/><link rel="up" href="reference-GLU.xml" title="GLU"/><link rel="previous" href="gluPartialDisk.3G.xml" title="gluPartialDisk"/><link rel="next" href="gluPickMatrix.3G.xml" title="gluPickMatrix"/></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gluPerspective</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="gluPartialDisk.3G.xml">Prev</a> </td><th width="60%" align="center">GLU</th><td width="20%" align="right"> <a accesskey="n" href="gluPickMatrix.3G.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="gluPerspective.3G"/><div class="titlepage"/><div class="refnamediv"><a name="gluPerspective.3G-name"/><h2>Name</h2><p>gluPerspective &#8212; set up a perspective projection matrix</p></div><div class="refsynopsisdiv"><a name="gluPerspective.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>void <tt>gluPerspective</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLdouble <i><tt>fovy</tt></i>, GLdouble <i><tt>aspect</tt></i>, GLdouble <i><tt>zNear</tt></i>, GLdouble <i><tt>zFar</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="gluPerspective.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>gluPerspective</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>fovy</tt></i>, <i><tt>aspect</tt></i>, <i><tt>zNear</tt></i>, <i><tt>zFar</tt></i>) &#8594; <tt>None</tt></code></td></tr></table></div><div class="refsect1" lang="en"><a name="gluPerspective.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>fovy</tt></i></span></dt><dd>
						Specifies the field of view angle, in degrees, in the <i><tt>y</tt></i> direction.
					</dd><dt><span class="term"><i><tt>aspect</tt></i></span></dt><dd>
						Specifies the aspect ratio that determines the field of view in the <i><tt>x</tt></i> direction. The
						aspect ratio is the ratio of <i><tt>x</tt></i> (width) to <i><tt>y</tt></i> (height).
					</dd><dt><span class="term"><i><tt>zNear</tt></i></span></dt><dd>
						Specifies the distance from the viewer to the near clipping plane (always positive).
					</dd><dt><span class="term"><i><tt>zFar</tt></i></span></dt><dd>
						Specifies the distance from the viewer to the far clipping plane (always positive).
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="gluPerspective.3G-description"/><h2>Description</h2><p>
			<tt>gluPerspective</tt> specifies a viewing frustum into the world coordinate system. In general, the
			aspect ratio in <tt>gluPerspective</tt> should match the aspect ratio of the associated viewport. For
			example, <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mi>aspect</mml:mi>
						<mml:mo>=</mml:mo>
						<mml:mn>2.0</mml:mn>
					</mml:mrow>
				</mml:math> means the viewer's angle of view is twice as wide in <i><tt>x</tt></i> as it is in
			<i><tt>y</tt></i>. If the viewport is twice as wide as it is tall, it displays the image without distortion.
		</p><p>
			The matrix generated by <tt>gluPerspective</tt> is multipled by the current matrix, just as if <tt>glMultMatrix</tt> were called with the generated matrix. To load the perspective matrix onto
			the current matrix stack instead, precede the call to <tt>gluPerspective</tt> with a call to <a href="glLoadIdentity.3G.xml"><tt>glLoadIdentity</tt></a>.
		</p><p>
			Given <i><tt>f</tt></i> defined as follows: </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" mode="display" overflow="scroll">
					<mml:mrow>
						<mml:mi>f</mml:mi>
						<mml:mo>=</mml:mo>
						<mml:mi>cotangent</mml:mi>
						<mml:mo>(</mml:mo>
						<mml:mfrac>
							<mml:mi>fovy</mml:mi>
							<mml:mn>2</mml:mn>
						</mml:mfrac>
						<mml:mo>)</mml:mo>
					</mml:mrow>
				</mml:math></div><p>The generated matrix is </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" mode="display" overflow="scroll">
					<mml:mrow>
						<mml:mo>(</mml:mo>
						<mml:mtable>
							<mml:mtr>
								<mml:mtd columnalign="center">
									<mml:mfrac>
										<mml:mi>f</mml:mi>
										<mml:mi>aspect</mml:mi>
									</mml:mfrac>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
							</mml:mtr>
							<mml:mtr>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mi>f</mml:mi>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
							</mml:mtr>
							<mml:mtr>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mfrac>
										<mml:mrow>
											<mml:mi>zFar</mml:mi>
											<mml:mo>+</mml:mo>
											<mml:mi>zNear</mml:mi>
										</mml:mrow>
										<mml:mrow>
											<mml:mi>zNear</mml:mi>
											<mml:mo>-</mml:mo>
											<mml:mi>zFar</mml:mi>
										</mml:mrow>
									</mml:mfrac>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mfrac>
										<mml:mrow>
											<mml:mn>2</mml:mn>
											<mml:mo>*</mml:mo>
											<mml:mi>zFar</mml:mi>
											<mml:mo>*</mml:mo>
											<mml:mi>zNear</mml:mi>
										</mml:mrow>
										<mml:mrow>
											<mml:mi>zNear</mml:mi>
											<mml:mo>-</mml:mo>
											<mml:mi>zFar</mml:mi>
										</mml:mrow>
									</mml:mfrac>
								</mml:mtd>
							</mml:mtr>
							<mml:mtr>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>-1</mml:mn>
								</mml:mtd>
								<mml:mtd columnalign="center">
									<mml:mn>0</mml:mn>
								</mml:mtd>
							</mml:mtr>
						</mml:mtable>
						<mml:mo>)</mml:mo>
					</mml:mrow>
				</mml:math></div><p>
		</p></div><div class="refsect1" lang="en"><a name="gluPerspective.3G-notes"/><h2>Notes</h2><p>
			Depth buffer precision is affected by the values specified for <i><tt>zNear</tt></i> and
			<i><tt>zFar</tt></i>. The greater the ratio of <i><tt>zFar</tt></i> to <i><tt>zNear</tt></i> is,
			the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If
			<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mi>r</mml:mi>
						<mml:mo>=</mml:mo>
						<mml:mfrac>
							<mml:mi>zFar</mml:mi>
							<mml:mi>zNear</mml:mi>
						</mml:mfrac>
					</mml:mrow>
				</mml:math>
		</p><p>
			roughly <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:msub>
							<mml:mi>log</mml:mi>
							<mml:mn>2</mml:mn>
						</mml:msub>
						<mml:mi>r</mml:mi>
					</mml:mrow>
				</mml:math> bits of depth buffer precision are lost. Because <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>r</mml:mi>
				</mml:math> approaches infinity as <i><tt>zNear</tt></i> approaches 0, <i><tt>zNear</tt></i> must
			never be set to 0.
		</p></div><div class="refsect1" lang="en"><a name="gluPerspective.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glFrustum.3G.xml">glFrustum</a>, <a href="glLoadIdentity.3G.xml">glLoadIdentity</a>, <a href="glMultMatrix.3G.xml">glMultMatrix</a>, <a href="gluOrtho2D.3G.xml">gluOrtho2D</a></span>
		</p></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="gluPartialDisk.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GLU.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="gluPickMatrix.3G.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gluPartialDisk </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> gluPickMatrix</td></tr></table></div></body></html>