Issue 2188: Documentation hint about disabling proxy detection.
[python.git] / Doc / library / gl.rst
blob8398a8e85cf18ad17a8d375caeee55e548931d65
2 :mod:`gl` --- *Graphics Library* interface
3 ==========================================
5 .. module:: gl
6    :platform: IRIX
7    :synopsis: Functions from the Silicon Graphics Graphics Library.
10 This module provides access to the Silicon Graphics *Graphics Library*. It is
11 available only on Silicon Graphics machines.
13 .. warning::
15    Some illegal calls to the GL library cause the Python interpreter to dump core.
16    In particular, the use of most GL calls is unsafe before the first window is
17    opened.
19 The module is too large to document here in its entirety, but the following
20 should help you to get started. The parameter conventions for the C functions
21 are translated to Python as follows:
23 * All (short, long, unsigned) int values are represented by Python integers.
25 * All float and double values are represented by Python floating point numbers.
26   In most cases, Python integers are also allowed.
28 * All arrays are represented by one-dimensional Python lists. In most cases,
29   tuples are also allowed.
31 * All string and character arguments are represented by Python strings, for
32   instance, ``winopen('Hi There!')`` and ``rotate(900, 'z')``.
34 * All (short, long, unsigned) integer arguments or return values that are only
35   used to specify the length of an array argument are omitted. For example, the C
36   call ::
38      lmdef(deftype, index, np, props)
40   is translated to Python as ::
42      lmdef(deftype, index, props)
44 * Output arguments are omitted from the argument list; they are transmitted as
45   function return values instead. If more than one value must be returned, the
46   return value is a tuple. If the C function has both a regular return value (that
47   is not omitted because of the previous rule) and an output argument, the return
48   value comes first in the tuple. Examples: the C call ::
50      getmcolor(i, &red, &green, &blue)
52   is translated to Python as ::
54      red, green, blue = getmcolor(i)
56 The following functions are non-standard or have special argument conventions:
59 .. function:: varray(argument)
61    Equivalent to but faster than a number of ``v3d()`` calls. The *argument* is a
62    list (or tuple) of points. Each point must be a tuple of coordinates ``(x, y,
63    z)`` or ``(x, y)``. The points may be 2- or 3-dimensional but must all have the
64    same dimension. Float and int values may be mixed however. The points are always
65    converted to 3D double precision points by assuming ``z = 0.0`` if necessary (as
66    indicated in the man page), and for each point ``v3d()`` is called.
68    .. XXX the argument-argument added
71 .. function:: nvarray()
73    Equivalent to but faster than a number of ``n3f`` and ``v3f`` calls. The
74    argument is an array (list or tuple) of pairs of normals and points. Each pair
75    is a tuple of a point and a normal for that point. Each point or normal must be
76    a tuple of coordinates ``(x, y, z)``. Three coordinates must be given. Float and
77    int values may be mixed. For each pair, ``n3f()`` is called for the normal, and
78    then ``v3f()`` is called for the point.
81 .. function:: vnarray()
83    Similar to  ``nvarray()`` but the pairs have the point first and the normal
84    second.
87 .. function:: nurbssurface(s_k, t_k, ctl, s_ord, t_ord, type)
89    Defines a nurbs surface. The dimensions of ``ctl[][]`` are computed as follows:
90    ``[len(s_k) - s_ord]``, ``[len(t_k) - t_ord]``.
92    .. XXX s_k[], t_k[], ctl[][]
95 .. function:: nurbscurve(knots, ctlpoints, order, type)
97    Defines a nurbs curve. The length of ctlpoints is ``len(knots) - order``.
100 .. function:: pwlcurve(points, type)
102    Defines a piecewise-linear curve. *points* is a list of points. *type* must be
103    ``N_ST``.
106 .. function:: pick(n)
107               select(n)
109    The only argument to these functions specifies the desired size of the pick or
110    select buffer.
113 .. function:: endpick()
114               endselect()
116    These functions have no arguments. They return a list of integers representing
117    the used part of the pick/select buffer. No method is provided to detect buffer
118    overrun.
120 Here is a tiny but complete example GL program in Python::
122    import gl, GL, time
124    def main():
125        gl.foreground()
126        gl.prefposition(500, 900, 500, 900)
127        w = gl.winopen('CrissCross')
128        gl.ortho2(0.0, 400.0, 0.0, 400.0)
129        gl.color(GL.WHITE)
130        gl.clear()
131        gl.color(GL.RED)
132        gl.bgnline()
133        gl.v2f(0.0, 0.0)
134        gl.v2f(400.0, 400.0)
135        gl.endline()
136        gl.bgnline()
137        gl.v2f(400.0, 0.0)
138        gl.v2f(0.0, 400.0)
139        gl.endline()
140        time.sleep(5)
142    main()
145 .. seealso::
147    `PyOpenGL: The Python OpenGL Binding <http://pyopengl.sourceforge.net/>`_
148       .. index::
149          single: OpenGL
150          single: PyOpenGL
152       An interface to OpenGL is also available; see information about the **PyOpenGL**
153       project online at http://pyopengl.sourceforge.net/.  This may be a better option
154       if support for SGI hardware from before about 1996 is not required.
157 :mod:`DEVICE` --- Constants used with the :mod:`gl` module
158 ==========================================================
160 .. module:: DEVICE
161    :platform: IRIX
162    :synopsis: Constants used with the gl module.
165 This modules defines the constants used by the Silicon Graphics *Graphics
166 Library* that C programmers find in the header file ``<gl/device.h>``. Read the
167 module source file for details.
170 :mod:`GL` --- Constants used with the :mod:`gl` module
171 ======================================================
173 .. module:: GL
174    :platform: IRIX
175    :synopsis: Constants used with the gl module.
178 This module contains constants used by the Silicon Graphics *Graphics Library*
179 from the C header file ``<gl/gl.h>``. Read the module source file for details.