blob: 69404378f8b06b47196552ff3005aea326f48801 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{gl} ---
2 Functions from the Silicon Graphics \emph{Graphics Library}.}
Fred Drakeb91e9341998-07-23 17:59:49 +00003\declaremodule{builtin}{gl}
4
5\modulesynopsis{Functions from the Silicon Graphics \emph{Graphics Library}.}
6
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00007
8This module provides access to the Silicon Graphics
Fred Drakeaf8a0151998-01-14 14:51:31 +00009\emph{Graphics Library}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000010It is available only on Silicon Graphics machines.
11
12\strong{Warning:}
13Some illegal calls to the GL library cause the Python interpreter to dump
14core.
15In particular, the use of most GL calls is unsafe before the first
16window is opened.
17
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}
Guido van Rossume47da0a1997-07-17 16:34:52 +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}
Guido van Rossume47da0a1997-07-17 16:34:52 +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}
Guido van Rossume47da0a1997-07-17 16:34:52 +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}
Guido van Rossume47da0a1997-07-17 16:34:52 +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 Rossume47da0a1997-07-17 16:34:52 +0000188%
Fred Drake295da241998-08-10 19:42:37 +0000189\section{\module{DEVICE} ---
190 Constants used with the \module{gl} module.}
Fred Drakeb91e9341998-07-23 17:59:49 +0000191\declaremodule{standard}{DEVICE}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000192
Fred Drakeb91e9341998-07-23 17:59:49 +0000193\modulesynopsis{Constants used with the \module{gl} module.}
194
195This modules defines the constants used by the Silicon Graphics
196\emph{Graphics Library} that C programmers find in the header file
197\code{<gl/device.h>}.
198Read the module source file for details.
199
200
Fred Drake295da241998-08-10 19:42:37 +0000201\section{\module{GL} ---
202 Constants used with the \module{gl} module.}
Fred Drakeb91e9341998-07-23 17:59:49 +0000203\declaremodule{standard}{GL}
204
205\modulesynopsis{Constants used with the \module{gl} module.}
206
207This module contains constants used by the Silicon Graphics
208\emph{Graphics Library} from the C header file \code{<gl/gl.h>}.
209Read the module source file for details.