Commit | Line | Data |
---|---|---|
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"> | |
56 | 20.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> | |
66 | This module provides access to the Silicon Graphics | |
67 | <em>Graphics Library</em>. | |
68 | It is available only on Silicon Graphics machines. | |
69 | ||
70 | <P> | |
71 | <span class="warning"><b class="label">Warning:</b> | |
72 | Some illegal calls to the GL library cause the Python | |
73 | interpreter to dump core. | |
74 | In particular, the use of most GL calls is unsafe before the first | |
75 | window is opened.</span> | |
76 | ||
77 | <P> | |
78 | The module is too large to document here in its entirety, but the | |
79 | following should help you to get started. | |
80 | The parameter conventions for the C functions are translated to Python as | |
81 | follows: | |
82 | ||
83 | <P> | |
84 | ||
85 | <UL> | |
86 | <LI>All (short, long, unsigned) int values are represented by Python | |
87 | integers. | |
88 | </LI> | |
89 | <LI>All float and double values are represented by Python floating point | |
90 | numbers. | |
91 | In most cases, Python integers are also allowed. | |
92 | </LI> | |
93 | <LI>All arrays are represented by one-dimensional Python lists. | |
94 | In most cases, tuples are also allowed. | |
95 | </LI> | |
96 | <LI>All string and character arguments are represented by Python strings, | |
97 | for instance, | |
98 | <code>winopen('Hi There!')</code> | |
99 | and | |
100 | <code>rotate(900, 'z')</code>. | |
101 | ||
102 | </LI> | |
103 | <LI>All (short, long, unsigned) integer arguments or return values that are | |
104 | only used to specify the length of an array argument are omitted. | |
105 | For example, the C call | |
106 | ||
107 | <P> | |
108 | <div class="verbatim"><pre> | |
109 | lmdef(deftype, index, np, props) | |
110 | </pre></div> | |
111 | ||
112 | <P> | |
113 | is translated to Python as | |
114 | ||
115 | <P> | |
116 | <div class="verbatim"><pre> | |
117 | lmdef(deftype, index, props) | |
118 | </pre></div> | |
119 | ||
120 | <P> | |
121 | </LI> | |
122 | <LI>Output arguments are omitted from the argument list; they are | |
123 | transmitted as function return values instead. | |
124 | If more than one value must be returned, the return value is a tuple. | |
125 | If the C function has both a regular return value (that is not omitted | |
126 | because of the previous rule) and an output argument, the return value | |
127 | comes first in the tuple. | |
128 | Examples: the C call | |
129 | ||
130 | <P> | |
131 | <div class="verbatim"><pre> | |
132 | getmcolor(i, &red, &green, &blue) | |
133 | </pre></div> | |
134 | ||
135 | <P> | |
136 | is translated to Python as | |
137 | ||
138 | <P> | |
139 | <div class="verbatim"><pre> | |
140 | red, green, blue = getmcolor(i) | |
141 | </pre></div> | |
142 | ||
143 | <P> | |
144 | </LI> | |
145 | </UL> | |
146 | ||
147 | <P> | |
148 | The following functions are non-standard or have special argument | |
149 | conventions: | |
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> | |
156 | Equivalent to but faster than a number of | |
157 | <code>v3d()</code> | |
158 | calls. | |
159 | The <var>argument</var> is a list (or tuple) of points. | |
160 | Each 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>. | |
162 | The points may be 2- or 3-dimensional but must all have the | |
163 | same dimension. | |
164 | Float and int values may be mixed however. | |
165 | The points are always converted to 3D double precision points | |
166 | by assuming <code><var>z</var> = 0.0</code> if necessary (as indicated in the man page), | |
167 | and for each point | |
168 | <code>v3d()</code> | |
169 | is 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> | |
177 | Equivalent to but faster than a number of | |
178 | <code>n3f</code> | |
179 | and | |
180 | <code>v3f</code> | |
181 | calls. | |
182 | The argument is an array (list or tuple) of pairs of normals and points. | |
183 | Each pair is a tuple of a point and a normal for that point. | |
184 | Each point or normal must be a tuple of coordinates | |
185 | <code>(<var>x</var>, <var>y</var>, <var>z</var>)</code>. | |
186 | Three coordinates must be given. | |
187 | Float and int values may be mixed. | |
188 | For each pair, | |
189 | <code>n3f()</code> | |
190 | is called for the normal, and then | |
191 | <code>v3f()</code> | |
192 | is 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> | |
200 | Similar to | |
201 | <code>nvarray()</code> | |
202 | but 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> | |
210 | Defines a nurbs surface. | |
211 | The dimensions of | |
212 | <code><var>ctl</var>[][]</code> | |
213 | are 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> | |
223 | Defines a nurbs curve. | |
224 | The 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> | |
233 | Defines a piecewise-linear curve. | |
234 | <var>points</var> | |
235 | is a list of points. | |
236 | <var>type</var> | |
237 | must 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 | |
250 | pick 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. | |
262 | They return a list of integers representing the used part of the | |
263 | pick/select buffer. | |
264 | No method is provided to detect buffer overrun. | |
265 | </dl> | |
266 | ||
267 | <P> | |
268 | Here is a tiny but complete example GL program in Python: | |
269 | ||
270 | <P> | |
271 | <div class="verbatim"><pre> | |
272 | import gl, GL, time | |
273 | ||
274 | def 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 | ||
292 | main() | |
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> | |
351 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
352 | </ADDRESS> | |
353 | </BODY> | |
354 | </HTML> |