blob: cbc175ad154802b52b4e0c2b977c67191111ec5d [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
127 import gl, GL, time
128
129 def main():
130 gl.foreground()
131 gl.prefposition(500, 900, 500, 900)
132 w = gl.winopen('CrissCross')
133 gl.ortho2(0.0, 400.0, 0.0, 400.0)
134 gl.color(GL.WHITE)
135 gl.clear()
136 gl.color(GL.RED)
137 gl.bgnline()
138 gl.v2f(0.0, 0.0)
139 gl.v2f(400.0, 400.0)
140 gl.endline()
141 gl.bgnline()
142 gl.v2f(400.0, 0.0)
143 gl.v2f(0.0, 400.0)
144 gl.endline()
145 time.sleep(5)
146
147 main()
148
149
150.. seealso::
151
152 `PyOpenGL: The Python OpenGL Binding <http://pyopengl.sourceforge.net/>`_
153 .. index::
154 single: OpenGL
155 single: PyOpenGL
156
157 An interface to OpenGL is also available; see information about the **PyOpenGL**
158 project online at http://pyopengl.sourceforge.net/. This may be a better option
159 if support for SGI hardware from before about 1996 is not required.
160
161
162:mod:`DEVICE` --- Constants used with the :mod:`gl` module
163==========================================================
164
165.. module:: DEVICE
166 :platform: IRIX
167 :synopsis: Constants used with the gl module.
Brett Cannon94f25612008-05-15 04:34:17 +0000168 :deprecated:
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000169
170
Brett Cannon94f25612008-05-15 04:34:17 +0000171.. deprecated:: 2.6
172 The :mod:`DEVICE` module has been deprecated for removal in Python 3.0.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000173
174
175This modules defines the constants used by the Silicon Graphics *Graphics
176Library* that C programmers find in the header file ``<gl/device.h>``. Read the
177module source file for details.
178
179
180:mod:`GL` --- Constants used with the :mod:`gl` module
181======================================================
182
183.. module:: GL
184 :platform: IRIX
185 :synopsis: Constants used with the gl module.
Brett Cannon94f25612008-05-15 04:34:17 +0000186 :deprecated:
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000187
188
Brett Cannon94f25612008-05-15 04:34:17 +0000189.. deprecated:: 2.6
190 The :mod:`GL` module has been deprecated for removal in Python 3.0.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000191
192This module contains constants used by the Silicon Graphics *Graphics Library*
193from the C header file ``<gl/gl.h>``. Read the module source file for details.
194