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