Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-gl.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-DEVICE.html" />
13<link rel="prev" href="module-fm.html" />
14<link rel="parent" href="sgi.html" />
15<link rel="next" href="module-DEVICE.html" />
16<meta name='aesop' content='information' />
17<title>20.8 gl -- Graphics Library interface</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="20.7 fm "
25 href="module-fm.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="20. SGI IRIX Specific"
28 href="sgi.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="20.9 DEVICE "
31 href="module-DEVICE.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-fm.html">20.7 fm </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="sgi.html">20. SGI IRIX Specific</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-DEVICE.html">20.9 DEVICE </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0022800000000000000000">
5620.8 <tt class="module">gl</tt> --
57 <em>Graphics Library</em> interface</A>
58</H1>
59
60<P>
61<A NAME="module-gl"></A>
62<p class="availability">Availability: <span
63 class="platform">IRIX</span>.</p>
64
65<P>
66This module provides access to the Silicon Graphics
67<em>Graphics Library</em>.
68It is available only on Silicon Graphics machines.
69
70<P>
71<span class="warning"><b class="label">Warning:</b>
72Some illegal calls to the GL library cause the Python
73interpreter to dump core.
74In particular, the use of most GL calls is unsafe before the first
75window is opened.</span>
76
77<P>
78The module is too large to document here in its entirety, but the
79following should help you to get started.
80The parameter conventions for the C functions are translated to Python as
81follows:
82
83<P>
84
85<UL>
86<LI>All (short, long, unsigned) int values are represented by Python
87integers.
88</LI>
89<LI>All float and double values are represented by Python floating point
90numbers.
91In most cases, Python integers are also allowed.
92</LI>
93<LI>All arrays are represented by one-dimensional Python lists.
94In most cases, tuples are also allowed.
95</LI>
96<LI>All string and character arguments are represented by Python strings,
97for instance,
98<code>winopen('Hi There!')</code>
99and
100<code>rotate(900, 'z')</code>.
101
102</LI>
103<LI>All (short, long, unsigned) integer arguments or return values that are
104only used to specify the length of an array argument are omitted.
105For example, the C call
106
107<P>
108<div class="verbatim"><pre>
109lmdef(deftype, index, np, props)
110</pre></div>
111
112<P>
113is translated to Python as
114
115<P>
116<div class="verbatim"><pre>
117lmdef(deftype, index, props)
118</pre></div>
119
120<P>
121</LI>
122<LI>Output arguments are omitted from the argument list; they are
123transmitted as function return values instead.
124If more than one value must be returned, the return value is a tuple.
125If the C function has both a regular return value (that is not omitted
126because of the previous rule) and an output argument, the return value
127comes first in the tuple.
128Examples: the C call
129
130<P>
131<div class="verbatim"><pre>
132getmcolor(i, &amp;red, &amp;green, &amp;blue)
133</pre></div>
134
135<P>
136is translated to Python as
137
138<P>
139<div class="verbatim"><pre>
140red, green, blue = getmcolor(i)
141</pre></div>
142
143<P>
144</LI>
145</UL>
146
147<P>
148The following functions are non-standard or have special argument
149conventions:
150
151<P>
152<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
153 <td><nobr><b><tt id='l2h-5192' xml:id='l2h-5192' class="function">varray</tt></b>(</nobr></td>
154 <td><var>argument</var>)</td></tr></table></dt>
155<dd>
156Equivalent to but faster than a number of
157<code>v3d()</code>
158calls.
159The <var>argument</var> is a list (or tuple) of points.
160Each point must be a tuple of coordinates
161<code>(<var>x</var>, <var>y</var>, <var>z</var>)</code> or <code>(<var>x</var>, <var>y</var>)</code>.
162The points may be 2- or 3-dimensional but must all have the
163same dimension.
164Float and int values may be mixed however.
165The points are always converted to 3D double precision points
166by assuming <code><var>z</var> = 0.0</code> if necessary (as indicated in the man page),
167and for each point
168<code>v3d()</code>
169is called.
170</dl>
171
172<P>
173<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
174 <td><nobr><b><tt id='l2h-5193' xml:id='l2h-5193' class="function">nvarray</tt></b>(</nobr></td>
175 <td><var></var>)</td></tr></table></dt>
176<dd>
177Equivalent to but faster than a number of
178<code>n3f</code>
179and
180<code>v3f</code>
181calls.
182The argument is an array (list or tuple) of pairs of normals and points.
183Each pair is a tuple of a point and a normal for that point.
184Each point or normal must be a tuple of coordinates
185<code>(<var>x</var>, <var>y</var>, <var>z</var>)</code>.
186Three coordinates must be given.
187Float and int values may be mixed.
188For each pair,
189<code>n3f()</code>
190is called for the normal, and then
191<code>v3f()</code>
192is called for the point.
193</dl>
194
195<P>
196<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
197 <td><nobr><b><tt id='l2h-5194' xml:id='l2h-5194' class="function">vnarray</tt></b>(</nobr></td>
198 <td><var></var>)</td></tr></table></dt>
199<dd>
200Similar to
201<code>nvarray()</code>
202but the pairs have the point first and the normal second.
203</dl>
204
205<P>
206<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
207 <td><nobr><b><tt id='l2h-5195' xml:id='l2h-5195' class="function">nurbssurface</tt></b>(</nobr></td>
208 <td><var>s_k, t_k, ctl, s_ord, t_ord, type</var>)</td></tr></table></dt>
209<dd>
210Defines a nurbs surface.
211The dimensions of
212<code><var>ctl</var>[][]</code>
213are computed as follows:
214<code>[len(<var>s_k</var>) - <var>s_ord</var>]</code>,
215<code>[len(<var>t_k</var>) - <var>t_ord</var>]</code>.
216</dl>
217
218<P>
219<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
220 <td><nobr><b><tt id='l2h-5196' xml:id='l2h-5196' class="function">nurbscurve</tt></b>(</nobr></td>
221 <td><var>knots, ctlpoints, order, type</var>)</td></tr></table></dt>
222<dd>
223Defines a nurbs curve.
224The length of ctlpoints is
225<code>len(<var>knots</var>) - <var>order</var></code>.
226</dl>
227
228<P>
229<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
230 <td><nobr><b><tt id='l2h-5197' xml:id='l2h-5197' class="function">pwlcurve</tt></b>(</nobr></td>
231 <td><var>points, type</var>)</td></tr></table></dt>
232<dd>
233Defines a piecewise-linear curve.
234<var>points</var>
235is a list of points.
236<var>type</var>
237must be
238<code>N_ST</code>.
239</dl>
240
241<P>
242<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
243 <td><nobr><b><tt id='l2h-5198' xml:id='l2h-5198' class="function">pick</tt></b>(</nobr></td>
244 <td><var>n</var>)</td></tr></table></dt>
245<dd>
246<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
247 <td><nobr><b><tt class="function">select</tt></b>(</nobr></td>
248 <td><var>n</var>)</td></tr></table></dt>
249<dd>The only argument to these functions specifies the desired size of the
250pick or select buffer.
251</dl>
252
253<P>
254<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
255 <td><nobr><b><tt id='l2h-5200' xml:id='l2h-5200' class="function">endpick</tt></b>(</nobr></td>
256 <td><var></var>)</td></tr></table></dt>
257<dd>
258<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
259 <td><nobr><b><tt class="function">endselect</tt></b>(</nobr></td>
260 <td><var></var>)</td></tr></table></dt>
261<dd>These functions have no arguments.
262They return a list of integers representing the used part of the
263pick/select buffer.
264No method is provided to detect buffer overrun.
265</dl>
266
267<P>
268Here is a tiny but complete example GL program in Python:
269
270<P>
271<div class="verbatim"><pre>
272import gl, GL, time
273
274def main():
275 gl.foreground()
276 gl.prefposition(500, 900, 500, 900)
277 w = gl.winopen('CrissCross')
278 gl.ortho2(0.0, 400.0, 0.0, 400.0)
279 gl.color(GL.WHITE)
280 gl.clear()
281 gl.color(GL.RED)
282 gl.bgnline()
283 gl.v2f(0.0, 0.0)
284 gl.v2f(400.0, 400.0)
285 gl.endline()
286 gl.bgnline()
287 gl.v2f(400.0, 0.0)
288 gl.v2f(0.0, 400.0)
289 gl.endline()
290 time.sleep(5)
291
292main()
293</pre></div>
294
295<P>
296<div class="seealso">
297 <p class="heading">See Also:</p>
298
299 <dl compact="compact" class="seetitle">
300 <dt><em class="citetitle"><a href="http://pyopengl.sourceforge.net/"
301 >PyOpenGL: The Python OpenGL Binding</a></em></dt>
302 <dd>An interface to OpenGL<a id='l2h-5202' xml:id='l2h-5202'></a> is also available;
303 see information about the
304 <strong>PyOpenGL</strong><a id='l2h-5203' xml:id='l2h-5203'></a> project online at
305 <a class="url" href="http://pyopengl.sourceforge.net/">http://pyopengl.sourceforge.net/</a>. This may be a
306 better option if support for SGI hardware from before
307 about 1996 is not required.</dd>
308 </dl>
309</div>
310
311<P>
312
313<DIV CLASS="navigation">
314<div class='online-navigation'>
315<p></p><hr />
316<table align="center" width="100%" cellpadding="0" cellspacing="2">
317<tr>
318<td class='online-navigation'><a rel="prev" title="20.7 fm "
319 href="module-fm.html"><img src='../icons/previous.png'
320 border='0' height='32' alt='Previous Page' width='32' /></A></td>
321<td class='online-navigation'><a rel="parent" title="20. SGI IRIX Specific"
322 href="sgi.html"><img src='../icons/up.png'
323 border='0' height='32' alt='Up One Level' width='32' /></A></td>
324<td class='online-navigation'><a rel="next" title="20.9 DEVICE "
325 href="module-DEVICE.html"><img src='../icons/next.png'
326 border='0' height='32' alt='Next Page' width='32' /></A></td>
327<td align="center" width="100%">Python Library Reference</td>
328<td class='online-navigation'><a rel="contents" title="Table of Contents"
329 href="contents.html"><img src='../icons/contents.png'
330 border='0' height='32' alt='Contents' width='32' /></A></td>
331<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
332 border='0' height='32' alt='Module Index' width='32' /></a></td>
333<td class='online-navigation'><a rel="index" title="Index"
334 href="genindex.html"><img src='../icons/index.png'
335 border='0' height='32' alt='Index' width='32' /></A></td>
336</tr></table>
337<div class='online-navigation'>
338<b class="navlabel">Previous:</b>
339<a class="sectref" rel="prev" href="module-fm.html">20.7 fm </A>
340<b class="navlabel">Up:</b>
341<a class="sectref" rel="parent" href="sgi.html">20. SGI IRIX Specific</A>
342<b class="navlabel">Next:</b>
343<a class="sectref" rel="next" href="module-DEVICE.html">20.9 DEVICE </A>
344</div>
345</div>
346<hr />
347<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
348</DIV>
349<!--End of Navigation Panel-->
350<ADDRESS>
351See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
352</ADDRESS>
353</BODY>
354</HTML>