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