1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"glViewport">
9 <holder>Silicon Graphics, Inc.
</holder>
12 <refentrytitle>glViewport
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>glViewport
</refname>
17 <refpurpose>set the viewport
</refpurpose>
19 <refsynopsisdiv><title>C Specification
</title>
22 <funcdef>void
<function>glViewport
</function></funcdef>
23 <paramdef>GLint
<parameter>x
</parameter></paramdef>
24 <paramdef>GLint
<parameter>y
</parameter></paramdef>
25 <paramdef>GLsizei
<parameter>width
</parameter></paramdef>
26 <paramdef>GLsizei
<parameter>height
</parameter></paramdef>
30 <!-- eqn: ignoring delim $$ -->
31 <refsect1 id=
"parameters"><title>Parameters
</title>
34 <term><parameter>x
</parameter></term>
35 <term><parameter>y
</parameter></term>
38 Specify the lower left corner of the viewport rectangle,
39 in pixels. The initial value is (
0,
0).
44 <term><parameter>width
</parameter></term>
45 <term><parameter>height
</parameter></term>
48 Specify the width and height
50 When a GL context is first attached to a window,
51 <parameter>width
</parameter> and
<parameter>height
</parameter> are set to the dimensions of that
58 <refsect1 id=
"description"><title>Description
</title>
60 <function>glViewport
</function> specifies the affine transformation of
61 <inlineequation><mml:math><mml:mi mathvariant=
"italic">x
</mml:mi></mml:math></inlineequation>
63 <inlineequation><mml:math><mml:mi mathvariant=
"italic">y
</mml:mi></mml:math></inlineequation>
65 normalized device coordinates to window coordinates.
67 <inlineequation><mml:math>
68 <!-- eqn: (x sub nd, y sub nd):-->
69 <mml:mfenced open=
"(" close=
")">
70 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
71 <mml:mi mathvariant=
"italic">nd
</mml:mi>
73 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
74 <mml:mi mathvariant=
"italic">nd
</mml:mi>
77 </mml:math></inlineequation>
78 be normalized device coordinates.
79 Then the window coordinates
80 <inlineequation><mml:math>
81 <!-- eqn: (x sub w, y sub w):-->
82 <mml:mfenced open=
"(" close=
")">
83 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
84 <mml:mi mathvariant=
"italic">w
</mml:mi>
86 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
87 <mml:mi mathvariant=
"italic">w
</mml:mi>
90 </mml:math></inlineequation>
91 are computed as follows:
94 <informalequation><mml:math>
95 <!-- eqn: x sub w = ( x sub nd + 1 ) left ( width over 2 right ) + x:-->
97 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
98 <mml:mi mathvariant=
"italic">w
</mml:mi>
102 <mml:mfenced open=
"(" close=
")">
104 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
105 <mml:mi mathvariant=
"italic">nd
</mml:mi>
111 <mml:mo>⁢</mml:mo>
112 <mml:mfenced open=
"(" close=
")">
114 <mml:mi mathvariant=
"italic">width
</mml:mi>
119 <mml:mi mathvariant=
"italic">x
</mml:mi>
122 </mml:math></informalequation>
125 <informalequation><mml:math>
126 <!-- eqn: y sub w = ( y sub nd + 1 ) left ( height over 2 right ) + y:-->
128 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
129 <mml:mi mathvariant=
"italic">w
</mml:mi>
133 <mml:mfenced open=
"(" close=
")">
135 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
136 <mml:mi mathvariant=
"italic">nd
</mml:mi>
142 <mml:mo>⁢</mml:mo>
143 <mml:mfenced open=
"(" close=
")">
145 <mml:mi mathvariant=
"italic">height
</mml:mi>
150 <mml:mi mathvariant=
"italic">y
</mml:mi>
153 </mml:math></informalequation>
156 Viewport width and height are silently clamped
157 to a range that depends on the implementation.
158 To query this range, call
<citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
159 <constant>GL_MAX_VIEWPORT_DIMS
</constant>.
162 <refsect1 id=
"errors"><title>Errors
</title>
164 <constant>GL_INVALID_VALUE
</constant> is generated if either
<parameter>width
</parameter> or
<parameter>height
</parameter> is negative.
167 <constant>GL_INVALID_OPERATION
</constant> is generated if
<function>glViewport
</function>
168 is executed between the execution of
<citerefentry><refentrytitle>glBegin
</refentrytitle></citerefentry>
169 and the corresponding execution of
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
172 <refsect1 id=
"associatedgets"><title>Associated Gets
</title>
174 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_VIEWPORT
</constant>
177 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_MAX_VIEWPORT_DIMS
</constant>
180 <refsect1 id=
"seealso"><title>See Also
</title>
182 <citerefentry><refentrytitle>glDepthRange
</refentrytitle></citerefentry>
185 <refsect1 id=
"Copyright"><title>Copyright
</title>
187 Copyright
<trademark class=
"copyright"></trademark> 1991-
2006
188 Silicon Graphics, Inc. This document is licensed under the SGI
189 Free Software B License. For details, see
190 <ulink url=
"http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/
</ulink>.