<?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>glViewport</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-GL.xml" title="GL"/><link rel="previous" href="glVertexPointer.3G.xml" title="glVertexPointer"/><link rel="next" href="reference-GLU.xml" title="GLU"/></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">glViewport</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="glVertexPointer.3G.xml">Prev</a> </td><th width="60%" align="center">GL</th><td width="20%" align="right"> <a accesskey="n" href="reference-GLU.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="glViewport.3G"/><div class="titlepage"/><div class="refnamediv"><a name="glViewport.3G-name"/><h2>Name</h2><p>glViewport &#8212; set the viewport</p></div><div class="refsynopsisdiv"><a name="glViewport.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>void <tt>glViewport</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLint <i><tt>x</tt></i>, GLint <i><tt>y</tt></i>, GLsizei <i><tt>width</tt></i>, GLsizei <i><tt>height</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="glViewport.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>glViewport</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>) &#8594; <tt>None</tt></code></td></tr></table></div><div class="refsect1" lang="en"><a name="glViewport.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>x</tt></i>, </span><span class="term"><i><tt>y</tt></i></span></dt><dd>
						Specify the lower left corner of the viewport rectangle, in pixels. The initial value is <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mfenced separator=",">
									<mml:mn>0</mml:mn>
									<mml:mn>0</mml:mn>
								</mml:mfenced>
							</mml:math>.
					</dd><dt><span class="term"><i><tt>width</tt></i>, </span><span class="term"><i><tt>height</tt></i></span></dt><dd>
						Specify the width and height of the viewport. When a GL context is first attached to a window,
						<i><tt>width</tt></i> and <i><tt>height</tt></i> are set to the dimensions of that window.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="glViewport.3G-description"/><h2>Description</h2><p>
			<tt>glViewport</tt> specifies the affine transformation of <i><tt>x</tt></i> and
			<i><tt>y</tt></i> from normalized device coordinates to window coordinates. Let <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mfenced separator=",">
						<mml:msub>
							<mml:mi>x</mml:mi>
							<mml:mi>nd</mml:mi>
						</mml:msub>
						<mml:msub>
							<mml:mi>y</mml:mi>
							<mml:mi>nd</mml:mi>
						</mml:msub>
					</mml:mfenced>
				</mml:math> be normalized device coordinates. Then the window coordinates <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mfenced separator=",">
						<mml:msub>
							<mml:mi>x</mml:mi>
							<mml:mi>w</mml:mi>
						</mml:msub>
						<mml:msub>
							<mml:mi>y</mml:mi>
							<mml:mi>w</mml:mi>
						</mml:msub>
					</mml:mfenced>
				</mml:math> are computed as follows:
		</p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" mode="display" overflow="scroll">
				<mml:mtable>
					<mml:mtr>
						<mml:mtd>
							<mml:msub>
								<mml:mi>x</mml:mi>
								<mml:mi>w</mml:mi>
							</mml:msub>
							<mml:mo>=</mml:mo>
							<mml:mfenced separator=",">
								<mml:mrow>
									<mml:msub>
										<mml:mi>x</mml:mi>
										<mml:mi>nd</mml:mi>
									</mml:msub>
									<mml:mo>+</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:mfenced>
							<mml:mfenced separator=",">
								<mml:mfrac>
									<mml:mi>width</mml:mi>
									<mml:mn>2</mml:mn>
								</mml:mfrac>
							</mml:mfenced>
							<mml:mo>+</mml:mo>
							<mml:mi>x</mml:mi>
						</mml:mtd>
					</mml:mtr>
					<mml:mtr>
						<mml:mtd>
							<mml:msub>
								<mml:mi>y</mml:mi>
								<mml:mi>w</mml:mi>
							</mml:msub>
							<mml:mo>=</mml:mo>
							<mml:mfenced separator=",">
								<mml:mrow>
									<mml:msub>
										<mml:mi>y</mml:mi>
										<mml:mi>nd</mml:mi>
									</mml:msub>
									<mml:mo>+</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:mfenced>
							<mml:mfenced separator=",">
								<mml:mfrac>
									<mml:mi>height</mml:mi>
									<mml:mn>2</mml:mn>
								</mml:mfrac>
							</mml:mfenced>
							<mml:mo>+</mml:mo>
							<mml:mi>y</mml:mi>
						</mml:mtd>
					</mml:mtr>
				</mml:mtable>
			</mml:math></div><p>
			Viewport width and height are silently clamped to a range that depends on the implementation. To query this range, call
			<tt>glGet</tt> with argument <tt>GL_MAX_VIEWPORT_DIMS</tt>.
		</p></div><div class="refsect1" lang="en"><a name="glViewport.3G-errors"/><h2>Errors</h2><p>
			<tt>GL_INVALID_VALUE</tt> is generated if either <i><tt>width</tt></i> or
			<i><tt>height</tt></i> is negative.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <tt>glViewport</tt> is executed between the
			execution of <a href="glBegin.3G.xml"><tt>glBegin</tt></a> and the corresponding execution of <a href="glBegin.3G.xml"><tt>glEnd</tt></a>.
		</p></div><div class="refsect1" lang="en"><a name="glViewport.3G-associated_gets"/><h2>Associated Gets</h2><p>
			<tt>glGet</tt> with argument <tt>GL_VIEWPORT</tt>
		</p><p>
			<tt>glGet</tt> with argument <tt>GL_MAX_VIEWPORT_DIMS</tt>
		</p></div><div class="refsect1" lang="en"><a name="glViewport.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glDepthRange.3G.xml">glDepthRange</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="glVertexPointer.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GL.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="reference-GLU.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">glVertexPointer </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> GLU</td></tr></table></div></body></html>