blob: 6a0a92a1be5d15c71e19aa121424e89f7ffb83fe [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001
2:mod:`gl` --- *Graphics Library* interface
3==========================================
4
5.. module:: gl
6 :platform: IRIX
7 :synopsis: Functions from the Silicon Graphics Graphics Library.
Brett Cannon94f25612008-05-15 04:34:17 +00008 :deprecated:
Georg Brandlc62ef8b2009-01-03 20:55:06 +00009
10
Brett Cannon94f25612008-05-15 04:34:17 +000011.. deprecated:: 2.6
12 The :mod:`gl` module has been deprecated for removal in Python 3.0.
Georg Brandl8ec7f652007-08-15 14:28:01 +000013
14
15This module provides access to the Silicon Graphics *Graphics Library*. It is
16available only on Silicon Graphics machines.
17
18.. warning::
19
20 Some illegal calls to the GL library cause the Python interpreter to dump core.
21 In particular, the use of most GL calls is unsafe before the first window is
22 opened.
23
24The module is too large to document here in its entirety, but the following
25should help you to get started. The parameter conventions for the C functions
26are translated to Python as follows:
27
28* All (short, long, unsigned) int values are represented by Python integers.
29
30* All float and double values are represented by Python floating point numbers.
31 In most cases, Python integers are also allowed.
32
33* All arrays are represented by one-dimensional Python lists. In most cases,
34 tuples are also allowed.
35
36* All string and character arguments are represented by Python strings, for
37 instance, ``winopen('Hi There!')`` and ``rotate(900, 'z')``.
38
39* All (short, long, unsigned) integer arguments or return values that are only
40 used to specify the length of an array argument are omitted. For example, the C
41 call ::
42
43 lmdef(deftype, index, np, props)
44
45 is translated to Python as ::
46
47 lmdef(deftype, index, props)
48
49* Output arguments are omitted from the argument list; they are transmitted as
50 function return values instead. If more than one value must be returned, the
51 return value is a tuple. If the C function has both a regular return value (that
52 is not omitted because of the previous rule) and an output argument, the return
53 value comes first in the tuple. Examples: the C call ::
54
55 getmcolor(i, &red, &green, &blue)
56
57 is translated to Python as ::
58
59 red, green, blue = getmcolor(i)
60
61The following functions are non-standard or have special argument conventions:
62
63
64.. function:: varray(argument)
65
66 Equivalent to but faster than a number of ``v3d()`` calls. The *argument* is a
67 list (or tuple) of points. Each point must be a tuple of coordinates ``(x, y,
68 z)`` or ``(x, y)``. The points may be 2- or 3-dimensional but must all have the
69 same dimension. Float and int values may be mixed however. The points are always
70 converted to 3D double precision points by assuming ``z = 0.0`` if necessary (as
71 indicated in the man page), and for each point ``v3d()`` is called.
72
Georg Brandlb19be572007-12-29 10:57:00 +000073 .. XXX the argument-argument added
Georg Brandl8ec7f652007-08-15 14:28:01 +000074
75
76.. function:: nvarray()
77
78 Equivalent to but faster than a number of ``n3f`` and ``v3f`` calls. The
79 argument is an array (list or tuple) of pairs of normals and points. Each pair
80 is a tuple of a point and a normal for that point. Each point or normal must be
81 a tuple of coordinates ``(x, y, z)``. Three coordinates must be given. Float and
82 int values may be mixed. For each pair, ``n3f()`` is called for the normal, and
83 then ``v3f()`` is called for the point.
84
85
86.. function:: vnarray()
87
88 Similar to ``nvarray()`` but the pairs have the point first and the normal
89 second.
90
91
92.. function:: nurbssurface(s_k, t_k, ctl, s_ord, t_ord, type)
93
94 Defines a nurbs surface. The dimensions of ``ctl[][]`` are computed as follows:
95 ``[len(s_k) - s_ord]``, ``[len(t_k) - t_ord]``.
96
Georg Brandlb19be572007-12-29 10:57:00 +000097 .. XXX s_k[], t_k[], ctl[][]
Georg Brandl8ec7f652007-08-15 14:28:01 +000098
99
100.. function:: nurbscurve(knots, ctlpoints, order, type)
101
102 Defines a nurbs curve. The length of ctlpoints is ``len(knots) - order``.
103
104
105.. function:: pwlcurve(points, type)
106
107 Defines a piecewise-linear curve. *points* is a list of points. *type* must be
108 ``N_ST``.
109
110
111.. function:: pick(n)
112 select(n)
113
114 The only argument to these functions specifies the desired size of the pick or
115 select buffer.
116
117
118.. function:: endpick()
119 endselect()
120
121 These functions have no arguments. They return a list of integers representing
122 the used part of the pick/select buffer. No method is provided to detect buffer
123 overrun.
124
125Here is a tiny but complete example GL program in Python::
126
Jeroen Ruigrok van der Werven51497422009-02-19 18:52:21 +0000127 import gl
128 import GL
129 import time
Georg Brandl8ec7f652007-08-15 14:28:01 +0000130
131 def main():
132 gl.foreground()
133 gl.prefposition(500, 900, 500, 900)
134 w = gl.winopen('CrissCross')
135 gl.ortho2(0.0, 400.0, 0.0, 400.0)
136 gl.color(GL.WHITE)
137 gl.clear()
138 gl.color(GL.RED)
139 gl.bgnline()
140 gl.v2f(0.0, 0.0)
141 gl.v2f(400.0, 400.0)
142 gl.endline()
143 gl.bgnline()
144 gl.v2f(400.0, 0.0)
145 gl.v2f(0.0, 400.0)
146 gl.endline()
147 time.sleep(5)
148
149 main()
150
151
152.. seealso::
153
154 `PyOpenGL: The Python OpenGL Binding <http://pyopengl.sourceforge.net/>`_
155 .. index::
156 single: OpenGL
157 single: PyOpenGL
158
159 An interface to OpenGL is also available; see information about the **PyOpenGL**
160 project online at http://pyopengl.sourceforge.net/. This may be a better option
161 if support for SGI hardware from before about 1996 is not required.
162
163
164:mod:`DEVICE` --- Constants used with the :mod:`gl` module
165==========================================================
166
167.. module:: DEVICE
168 :platform: IRIX
169 :synopsis: Constants used with the gl module.
Brett Cannon94f25612008-05-15 04:34:17 +0000170 :deprecated:
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000171
172
Brett Cannon94f25612008-05-15 04:34:17 +0000173.. deprecated:: 2.6
174 The :mod:`DEVICE` module has been deprecated for removal in Python 3.0.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000175
176
177This modules defines the constants used by the Silicon Graphics *Graphics
178Library* that C programmers find in the header file ``<gl/device.h>``. Read the
179module source file for details.
180
181
182:mod:`GL` --- Constants used with the :mod:`gl` module
183======================================================
184
185.. module:: GL
186 :platform: IRIX
187 :synopsis: Constants used with the gl module.
Brett Cannon94f25612008-05-15 04:34:17 +0000188 :deprecated:
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000189
190
Brett Cannon94f25612008-05-15 04:34:17 +0000191.. deprecated:: 2.6
192 The :mod:`GL` module has been deprecated for removal in Python 3.0.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000193
194This module contains constants used by the Silicon Graphics *Graphics Library*
195from the C header file ``<gl/gl.h>``. Read the module source file for details.
196