blob: ecf4c367778109ffa85ff23e81f6316afb5fdd08 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{gl} ---
Fred Drake67d229e1999-02-20 04:51:16 +00002 \emph{Graphics Library} interface}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drake67d229e1999-02-20 04:51:16 +00004\declaremodule{builtin}{gl}
Fred Drakef6863c11999-03-02 16:37:17 +00005 \platform{IRIX}
Fred Drakeb91e9341998-07-23 17:59:49 +00006\modulesynopsis{Functions from the Silicon Graphics \emph{Graphics Library}.}
7
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00008
9This module provides access to the Silicon Graphics
Fred Drakeaf8a0151998-01-14 14:51:31 +000010\emph{Graphics Library}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000011It is available only on Silicon Graphics machines.
12
Fred Drake0aa811c2001-10-20 04:24:09 +000013\warning{Some illegal calls to the GL library cause the Python
14interpreter to dump core.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000015In particular, the use of most GL calls is unsafe before the first
Fred Drake0aa811c2001-10-20 04:24:09 +000016window is opened.}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000017
18The module is too large to document here in its entirety, but the
19following should help you to get started.
20The parameter conventions for the C functions are translated to Python as
21follows:
22
23\begin{itemize}
24\item
25All (short, long, unsigned) int values are represented by Python
26integers.
27\item
28All float and double values are represented by Python floating point
29numbers.
30In most cases, Python integers are also allowed.
31\item
32All arrays are represented by one-dimensional Python lists.
33In most cases, tuples are also allowed.
34\item
35\begin{sloppypar}
36All string and character arguments are represented by Python strings,
37for instance,
38\code{winopen('Hi There!')}
39and
40\code{rotate(900, 'z')}.
41\end{sloppypar}
42\item
43All (short, long, unsigned) integer arguments or return values that are
44only used to specify the length of an array argument are omitted.
45For example, the C call
46
Fred Drake19479911998-02-13 06:58:54 +000047\begin{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000048lmdef(deftype, index, np, props)
Fred Drake19479911998-02-13 06:58:54 +000049\end{verbatim}
Fred Drake505c4911999-04-27 18:05:06 +000050
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000051is translated to Python as
52
Fred Drake19479911998-02-13 06:58:54 +000053\begin{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000054lmdef(deftype, index, props)
Fred Drake19479911998-02-13 06:58:54 +000055\end{verbatim}
Fred Drake505c4911999-04-27 18:05:06 +000056
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000057\item
58Output arguments are omitted from the argument list; they are
59transmitted as function return values instead.
60If more than one value must be returned, the return value is a tuple.
61If the C function has both a regular return value (that is not omitted
62because of the previous rule) and an output argument, the return value
63comes first in the tuple.
64Examples: the C call
65
Fred Drake19479911998-02-13 06:58:54 +000066\begin{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000067getmcolor(i, &red, &green, &blue)
Fred Drake19479911998-02-13 06:58:54 +000068\end{verbatim}
Fred Drake505c4911999-04-27 18:05:06 +000069
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000070is translated to Python as
71
Fred Drake19479911998-02-13 06:58:54 +000072\begin{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000073red, green, blue = getmcolor(i)
Fred Drake19479911998-02-13 06:58:54 +000074\end{verbatim}
Fred Drake505c4911999-04-27 18:05:06 +000075
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000076\end{itemize}
77
78The following functions are non-standard or have special argument
79conventions:
80
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000081\begin{funcdesc}{varray}{argument}
82%JHXXX the argument-argument added
83Equivalent to but faster than a number of
84\code{v3d()}
85calls.
86The \var{argument} is a list (or tuple) of points.
87Each point must be a tuple of coordinates
88\code{(\var{x}, \var{y}, \var{z})} or \code{(\var{x}, \var{y})}.
89The points may be 2- or 3-dimensional but must all have the
90same dimension.
91Float and int values may be mixed however.
92The points are always converted to 3D double precision points
93by assuming \code{\var{z} = 0.0} if necessary (as indicated in the man page),
94and for each point
95\code{v3d()}
96is called.
97\end{funcdesc}
98
99\begin{funcdesc}{nvarray}{}
100Equivalent to but faster than a number of
101\code{n3f}
102and
103\code{v3f}
104calls.
105The argument is an array (list or tuple) of pairs of normals and points.
106Each pair is a tuple of a point and a normal for that point.
107Each point or normal must be a tuple of coordinates
108\code{(\var{x}, \var{y}, \var{z})}.
109Three coordinates must be given.
110Float and int values may be mixed.
111For each pair,
112\code{n3f()}
113is called for the normal, and then
114\code{v3f()}
115is called for the point.
116\end{funcdesc}
117
118\begin{funcdesc}{vnarray}{}
119Similar to
120\code{nvarray()}
121but the pairs have the point first and the normal second.
122\end{funcdesc}
123
Fred Drakecce10901998-03-17 06:33:25 +0000124\begin{funcdesc}{nurbssurface}{s_k, t_k, ctl, s_ord, t_ord, type}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000125% XXX s_k[], t_k[], ctl[][]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000126Defines a nurbs surface.
127The dimensions of
128\code{\var{ctl}[][]}
129are computed as follows:
130\code{[len(\var{s_k}) - \var{s_ord}]},
131\code{[len(\var{t_k}) - \var{t_ord}]}.
132\end{funcdesc}
133
Fred Drakecce10901998-03-17 06:33:25 +0000134\begin{funcdesc}{nurbscurve}{knots, ctlpoints, order, type}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000135Defines a nurbs curve.
136The length of ctlpoints is
137\code{len(\var{knots}) - \var{order}}.
138\end{funcdesc}
139
Fred Drakecce10901998-03-17 06:33:25 +0000140\begin{funcdesc}{pwlcurve}{points, type}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000141Defines a piecewise-linear curve.
142\var{points}
143is a list of points.
144\var{type}
145must be
146\code{N_ST}.
147\end{funcdesc}
148
149\begin{funcdesc}{pick}{n}
150\funcline{select}{n}
151The only argument to these functions specifies the desired size of the
152pick or select buffer.
153\end{funcdesc}
154
155\begin{funcdesc}{endpick}{}
156\funcline{endselect}{}
157These functions have no arguments.
158They return a list of integers representing the used part of the
159pick/select buffer.
160No method is provided to detect buffer overrun.
161\end{funcdesc}
162
163Here is a tiny but complete example GL program in Python:
164
Fred Drake19479911998-02-13 06:58:54 +0000165\begin{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000166import gl, GL, time
167
168def main():
169 gl.foreground()
170 gl.prefposition(500, 900, 500, 900)
171 w = gl.winopen('CrissCross')
172 gl.ortho2(0.0, 400.0, 0.0, 400.0)
173 gl.color(GL.WHITE)
174 gl.clear()
175 gl.color(GL.RED)
176 gl.bgnline()
177 gl.v2f(0.0, 0.0)
178 gl.v2f(400.0, 400.0)
179 gl.endline()
180 gl.bgnline()
181 gl.v2f(400.0, 0.0)
182 gl.v2f(0.0, 400.0)
183 gl.endline()
184 time.sleep(5)
185
186main()
Fred Drake19479911998-02-13 06:58:54 +0000187\end{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000188
Fred Drakef6863c11999-03-02 16:37:17 +0000189
Fred Drake505c4911999-04-27 18:05:06 +0000190\begin{seealso}
Fred Drake05a73b12001-09-06 19:23:03 +0000191 \seetitle[http://pyopengl.sourceforge.net/]
192 {PyOpenGL: The Python OpenGL Binding}
193 {An interface to OpenGL\index{OpenGL} is also available;
194 see information about the
195 \strong{PyOpenGL}\index{PyOpenGL} project online at
196 \url{http://pyopengl.sourceforge.net/}. This may be a
197 better option if support for SGI hardware from before
198 about 1996 is not required.}
Fred Drake505c4911999-04-27 18:05:06 +0000199\end{seealso}
200
201
Fred Drakef6863c11999-03-02 16:37:17 +0000202\section{\module{DEVICE} ---
203 Constants used with the \module{gl} module}
204
205\declaremodule{standard}{DEVICE}
206 \platform{IRIX}
Fred Drakeb91e9341998-07-23 17:59:49 +0000207\modulesynopsis{Constants used with the \module{gl} module.}
208
209This modules defines the constants used by the Silicon Graphics
210\emph{Graphics Library} that C programmers find in the header file
211\code{<gl/device.h>}.
212Read the module source file for details.
213
214
Fred Drake295da241998-08-10 19:42:37 +0000215\section{\module{GL} ---
Fred Drakef6863c11999-03-02 16:37:17 +0000216 Constants used with the \module{gl} module}
Fred Drakeb91e9341998-07-23 17:59:49 +0000217
Fred Drake93503ca1999-03-12 16:24:22 +0000218\declaremodule[gl-constants]{standard}{GL}
Fred Drakef6863c11999-03-02 16:37:17 +0000219 \platform{IRIX}
Fred Drakeb91e9341998-07-23 17:59:49 +0000220\modulesynopsis{Constants used with the \module{gl} module.}
221
222This module contains constants used by the Silicon Graphics
223\emph{Graphics Library} from the C header file \code{<gl/gl.h>}.
224Read the module source file for details.