<?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="&#xA;      PyOpenGL 2.0.1.04 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 class="refsect1" lang="en"><a name="glViewport.3G-python_samples"/><h2>Python Sample Code</h2><p>
            </p><div class="variablelist"><dl><dt><span class="term">glViewport</span></dt><dd><div class="itemizedlist"><ul type="disc"><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson1.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson1.py</a> Ln#72 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson18.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson18.py</a> Ln#138 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson2.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson2.py</a> Ln#72 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson3.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson3.py</a> Ln#72 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson4.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson4.py</a> Ln#82 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson5.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson5.py</a> Ln#85 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson6-multi.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson6-multi.py</a> Ln#125 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/NeHe/lesson6.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">NeHe/lesson6.py</a> Ln#107 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/da/dots.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">da/dots.py</a> Ln#91 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/cube.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/cube.py</a> Ln#82 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/double.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/double.py</a> Ln#94 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/drawf.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/drawf.py</a> Ln#92 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/fog.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/fog.py</a> Ln#120 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/lines.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/lines.py</a> Ln#126 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/movelight.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/movelight.py</a> Ln#117 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/scene.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/scene.py</a> Ln#113 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/smooth.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/smooth.py</a> Ln#91 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/redbook/teapots.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">redbook/teapots.py</a> Ln#175 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/simple/GLE.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">simple/GLE.py</a> Ln#58 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/suite/GLUT.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">suite/GLUT.py</a> Ln#36 </li><li>OpenGL/Demo/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/PyOpenGL2/OpenGL/Demo/twburton/knot.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">twburton/knot.py</a> Ln#206 </li><li>OpenGLContext/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyopengl/OpenGLContext/context.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">context.py</a> Ln#424 </li><li>SciPy/kiva/<a href="http://scipy.net/cgi-bin/viewcvsx.cgi/kiva/tests/test_glcore2d.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">tests/test_glcore2d.py</a> Ln#207 </li><li>{LGPL} PyUI/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pyui/PyUIcvs/pyui/renderers/openglGlut.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">pyui/renderers/openglGlut.py</a> Ln#229 </li><li>{LGPL} VisionEgg/<a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/visionegg/visionegg/src/Core.py?rev=HEAD&amp;content-type=text/vnd.viewcvs-markup" target="_top">src/Core.py</a> Ln#1025 </li></ul></div></dd></dl></div><p>
          </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>