Commit | Line | Data |
---|---|---|
7faf1d71 AW |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd"> | |
3 | <!-- saved from url=(0013)about:internet --> | |
4 | <?xml-stylesheet type="text/xsl" href="mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:pref="http://www.w3.org/2002/Math/preference" pref:renderer="mathplayer-dl"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" type="text/css" href="opengl-man.css" /><title>glViewport - OpenGL 4 Reference Pages</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="glViewport"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glViewport — set the viewport</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">glViewport</b>(</code></td><td>GLint </td><td><var class="pdparam">x</var>, </td></tr><tr><td> </td><td>GLint </td><td><var class="pdparam">y</var>, </td></tr><tr><td> </td><td>GLsizei </td><td><var class="pdparam">width</var>, </td></tr><tr><td> </td><td>GLsizei </td><td><var class="pdparam">height</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>x</code></em>, </span><span class="term"><em class="parameter"><code>y</code></em></span></dt><dd><p> | |
5 | Specify the lower left corner of the viewport rectangle, | |
6 | in pixels. The initial value is (0,0). | |
7 | </p></dd><dt><span class="term"><em class="parameter"><code>width</code></em>, </span><span class="term"><em class="parameter"><code>height</code></em></span></dt><dd><p> | |
8 | Specify the width and height | |
9 | of the viewport. | |
10 | When a GL context is first attached to a window, | |
11 | <em class="parameter"><code>width</code></em> and <em class="parameter"><code>height</code></em> are set to the dimensions of that | |
12 | window. | |
13 | </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p> | |
14 | <code class="function">glViewport</code> specifies the affine transformation of | |
15 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">x</mml:mi></mml:math> | |
16 | and | |
17 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">y</mml:mi></mml:math> | |
18 | from | |
19 | normalized device coordinates to window coordinates. | |
20 | Let | |
21 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
22 | ||
23 | <mml:mfenced open="(" close=")"> | |
24 | <mml:msub><mml:mi mathvariant="italic">x</mml:mi> | |
25 | <mml:mi mathvariant="italic">nd</mml:mi> | |
26 | </mml:msub> | |
27 | <mml:msub><mml:mi mathvariant="italic">y</mml:mi> | |
28 | <mml:mi mathvariant="italic">nd</mml:mi> | |
29 | </mml:msub> | |
30 | </mml:mfenced> | |
31 | </mml:math> | |
32 | be normalized device coordinates. | |
33 | Then the window coordinates | |
34 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
35 | ||
36 | <mml:mfenced open="(" close=")"> | |
37 | <mml:msub><mml:mi mathvariant="italic">x</mml:mi> | |
38 | <mml:mi mathvariant="italic">w</mml:mi> | |
39 | </mml:msub> | |
40 | <mml:msub><mml:mi mathvariant="italic">y</mml:mi> | |
41 | <mml:mi mathvariant="italic">w</mml:mi> | |
42 | </mml:msub> | |
43 | </mml:mfenced> | |
44 | </mml:math> | |
45 | are computed as follows: | |
46 | </p><p> | |
47 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
48 | ||
49 | <mml:mrow> | |
50 | <mml:msub><mml:mi mathvariant="italic">x</mml:mi> | |
51 | <mml:mi mathvariant="italic">w</mml:mi> | |
52 | </mml:msub> | |
53 | <mml:mo>=</mml:mo> | |
54 | <mml:mrow> | |
55 | <mml:mfenced open="(" close=")"> | |
56 | <mml:mrow> | |
57 | <mml:msub><mml:mi mathvariant="italic">x</mml:mi> | |
58 | <mml:mi mathvariant="italic">nd</mml:mi> | |
59 | </mml:msub> | |
60 | <mml:mo>+</mml:mo> | |
61 | <mml:mn>1</mml:mn> | |
62 | </mml:mrow> | |
63 | </mml:mfenced> | |
64 | <mml:mo></mml:mo> | |
65 | <mml:mfenced open="(" close=")"> | |
66 | <mml:mfrac> | |
67 | <mml:mi mathvariant="italic">width</mml:mi> | |
68 | <mml:mn>2</mml:mn> | |
69 | </mml:mfrac> | |
70 | </mml:mfenced> | |
71 | <mml:mo>+</mml:mo> | |
72 | <mml:mi mathvariant="italic">x</mml:mi> | |
73 | </mml:mrow> | |
74 | </mml:mrow> | |
75 | </mml:math></div><p> | |
76 | </p><p> | |
77 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
78 | ||
79 | <mml:mrow> | |
80 | <mml:msub><mml:mi mathvariant="italic">y</mml:mi> | |
81 | <mml:mi mathvariant="italic">w</mml:mi> | |
82 | </mml:msub> | |
83 | <mml:mo>=</mml:mo> | |
84 | <mml:mrow> | |
85 | <mml:mfenced open="(" close=")"> | |
86 | <mml:mrow> | |
87 | <mml:msub><mml:mi mathvariant="italic">y</mml:mi> | |
88 | <mml:mi mathvariant="italic">nd</mml:mi> | |
89 | </mml:msub> | |
90 | <mml:mo>+</mml:mo> | |
91 | <mml:mn>1</mml:mn> | |
92 | </mml:mrow> | |
93 | </mml:mfenced> | |
94 | <mml:mo></mml:mo> | |
95 | <mml:mfenced open="(" close=")"> | |
96 | <mml:mfrac> | |
97 | <mml:mi mathvariant="italic">height</mml:mi> | |
98 | <mml:mn>2</mml:mn> | |
99 | </mml:mfrac> | |
100 | </mml:mfenced> | |
101 | <mml:mo>+</mml:mo> | |
102 | <mml:mi mathvariant="italic">y</mml:mi> | |
103 | </mml:mrow> | |
104 | </mml:mrow> | |
105 | </mml:math></div><p> | |
106 | </p><p> | |
107 | Viewport width and height are silently clamped | |
108 | to a range that depends on the implementation. | |
109 | To query this range, call <a href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument | |
110 | <code class="constant">GL_MAX_VIEWPORT_DIMS</code>. | |
111 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p> | |
112 | <code class="constant">GL_INVALID_VALUE</code> is generated if either <em class="parameter"><code>width</code></em> or <em class="parameter"><code>height</code></em> is negative. | |
113 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="associatedgets"></a><h2>Associated Gets</h2><p> | |
114 | <a href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_VIEWPORT</code> | |
115 | </p><p> | |
116 | <a href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_MAX_VIEWPORT_DIMS</code> | |
117 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p> | |
118 | <a href="glDepthRange.xml"><span class="citerefentry"><span class="refentrytitle">glDepthRange</span></span></a> | |
119 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p> | |
120 | Copyright <span class="trademark"></span>© 1991-2006 | |
121 | Silicon Graphics, Inc. This document is licensed under the SGI | |
122 | Free Software B License. For details, see | |
123 | <a href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>. | |
124 | </p></div></div></body></html> |