⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-gl.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>18.8 gl -- Graphics Library interface</title>
<META NAME="description" CONTENT="18.8 gl -- Graphics Library interface">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-DEVICE.html" tppabs="http://www.python.org/doc/current/lib/module-DEVICE.html">
<LINK REL="previous" href="module-fm.html" tppabs="http://www.python.org/doc/current/lib/module-fm.html">
<LINK REL="up" href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html">
<LINK REL="next" href="module-DEVICE.html" tppabs="http://www.python.org/doc/current/lib/module-DEVICE.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-fm.html" tppabs="http://www.python.org/doc/current/lib/module-fm.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="module-DEVICE.html" tppabs="http://www.python.org/doc/current/lib/module-DEVICE.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-fm.html" tppabs="http://www.python.org/doc/current/lib/module-fm.html">18.7 fm  </A>
<b class="navlabel">Up:</b> <a class="sectref" href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html">18. SGI IRIX Specific</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-DEVICE.html" tppabs="http://www.python.org/doc/current/lib/module-DEVICE.html">18.9 DEVICE  </A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0020800000000000000000">
18.8 <tt class="module">gl</tt> --
         <i>Graphics Library</i> interface</A>
</H1>

<P>
  
<p class='availability'>Availability: <span
 class='platform'>IRIX</span>.</p>

<P>
This module provides access to the Silicon Graphics
<i>Graphics Library</i>.
It is available only on Silicon Graphics machines.

<P>
<b>Warning:</b>
Some illegal calls to the GL library cause the Python interpreter to dump
core.
In particular, the use of most GL calls is unsafe before the first
window is opened.

<P>
The module is too large to document here in its entirety, but the
following should help you to get started.
The parameter conventions for the C functions are translated to Python as
follows:

<P>

<UL>
<LI>All (short, long, unsigned) int values are represented by Python
integers.
</LI>
<LI>All float and double values are represented by Python floating point
numbers.
In most cases, Python integers are also allowed.
</LI>
<LI>All arrays are represented by one-dimensional Python lists.
In most cases, tuples are also allowed.
</LI>
<LI>All string and character arguments are represented by Python strings,
for instance,
<code>winopen('Hi There!')</code>
and
<code>rotate(900, 'z')</code>.

</LI>
<LI>All (short, long, unsigned) integer arguments or return values that are
only used to specify the length of an array argument are omitted.
For example, the C call

<P>
<dl><dd><pre class="verbatim">
lmdef(deftype, index, np, props)
</pre></dl>

<P>
is translated to Python as

<P>
<dl><dd><pre class="verbatim">
lmdef(deftype, index, props)
</pre></dl>

<P>
</LI>
<LI>Output arguments are omitted from the argument list; they are
transmitted as function return values instead.
If more than one value must be returned, the return value is a tuple.
If the C function has both a regular return value (that is not omitted
because of the previous rule) and an output argument, the return value
comes first in the tuple.
Examples: the C call

<P>
<dl><dd><pre class="verbatim">
getmcolor(i, &amp;red, &amp;green, &amp;blue)
</pre></dl>

<P>
is translated to Python as

<P>
<dl><dd><pre class="verbatim">
red, green, blue = getmcolor(i)
</pre></dl>

<P>
</LI>
</UL>

<P>
The following functions are non-standard or have special argument
conventions:

<P>
<dl><dt><b><a name='l2h-3233'><tt class='function'>varray</tt></a></b> (<var>argument</var>)
<dd>
Equivalent to but faster than a number of
<code>v3d()</code>
calls.
The <var>argument</var> is a list (or tuple) of points.
Each point must be a tuple of coordinates
<code>(<var>x</var>, <var>y</var>, <var>z</var>)</code> or <code>(<var>x</var>, <var>y</var>)</code>.
The points may be 2- or 3-dimensional but must all have the
same dimension.
Float and int values may be mixed however.
The points are always converted to 3D double precision points
by assuming <code><var>z</var> = 0.0</code> if necessary (as indicated in the man page),
and for each point
<code>v3d()</code>
is called.
</dl>

<P>
<dl><dt><b><a name='l2h-3234'><tt class='function'>nvarray</tt></a></b> ()
<dd>
Equivalent to but faster than a number of
<code>n3f</code>
and
<code>v3f</code>
calls.
The argument is an array (list or tuple) of pairs of normals and points.
Each pair is a tuple of a point and a normal for that point.
Each point or normal must be a tuple of coordinates
<code>(<var>x</var>, <var>y</var>, <var>z</var>)</code>.
Three coordinates must be given.
Float and int values may be mixed.
For each pair,
<code>n3f()</code>
is called for the normal, and then
<code>v3f()</code>
is called for the point.
</dl>

<P>
<dl><dt><b><a name='l2h-3235'><tt class='function'>vnarray</tt></a></b> ()
<dd>
Similar to 
<code>nvarray()</code>
but the pairs have the point first and the normal second.
</dl>

<P>
<dl><dt><b><a name='l2h-3236'><tt class='function'>nurbssurface</tt></a></b> (<var>s_k, t_k, ctl, s_ord, t_ord, type</var>)
<dd>
Defines a nurbs surface.
The dimensions of
<code><var>ctl</var>[][]</code>
are computed as follows:
<code>[len(<var>s_k</var>) - <var>s_ord</var>]</code>,
<code>[len(<var>t_k</var>) - <var>t_ord</var>]</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-3237'><tt class='function'>nurbscurve</tt></a></b> (<var>knots, ctlpoints, order, type</var>)
<dd>
Defines a nurbs curve.
The length of ctlpoints is
<code>len(<var>knots</var>) - <var>order</var></code>.
</dl>

<P>
<dl><dt><b><a name='l2h-3238'><tt class='function'>pwlcurve</tt></a></b> (<var>points, type</var>)
<dd>
Defines a piecewise-linear curve.
<var>points</var>
is a list of points.
<var>type</var>
must be
<code>N_ST</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-3239'><tt class='function'>pick</tt></a></b> (<var>n</var>)
<dd>
<dt><b><tt class='function'>select</tt></b> (<var>n</var>)
<dd>
The only argument to these functions specifies the desired size of the
pick or select buffer.
</dl>

<P>
<dl><dt><b><a name='l2h-3240'><tt class='function'>endpick</tt></a></b> ()
<dd>
<dt><b><tt class='function'>endselect</tt></b> ()
<dd>
These functions have no arguments.
They return a list of integers representing the used part of the
pick/select buffer.
No method is provided to detect buffer overrun.
</dl>

<P>
Here is a tiny but complete example GL program in Python:

<P>
<dl><dd><pre class="verbatim">
import gl, GL, time

def main():
    gl.foreground()
    gl.prefposition(500, 900, 500, 900)
    w = gl.winopen('CrissCross')
    gl.ortho2(0.0, 400.0, 0.0, 400.0)
    gl.color(GL.WHITE)
    gl.clear()
    gl.color(GL.RED)
    gl.bgnline()
    gl.v2f(0.0, 0.0)
    gl.v2f(400.0, 400.0)
    gl.endline()
    gl.bgnline()
    gl.v2f(400.0, 0.0)
    gl.v2f(0.0, 400.0)
    gl.endline()
    time.sleep(5)

main()
</pre></dl>

<P>
<div class='seealso'>
  <p class='heading'><b>See Also:</b></p>

  <div class="seetext"><p>An interface to OpenGL is also available; see
           information about David Ascher's
           <b>PyOpenGL</b> online at
           <a class="url" href="javascript:if(confirm('http://starship.python.net/crew/da/PyOpenGL/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://starship.python.net/crew/da/PyOpenGL/'" tppabs="http://starship.python.net/crew/da/PyOpenGL/">http://starship.python.net/crew/da/PyOpenGL/ <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
  border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
  ></a>.  This may
           be a better option if support for SGI hardware from before about
           1996 is not required.</div>
</div>

<P>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-fm.html" tppabs="http://www.python.org/doc/current/lib/module-fm.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="module-DEVICE.html" tppabs="http://www.python.org/doc/current/lib/module-DEVICE.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-fm.html" tppabs="http://www.python.org/doc/current/lib/module-fm.html">18.7 fm  </A>
<b class="navlabel">Up:</b> <a class="sectref" href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html">18. SGI IRIX Specific</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-DEVICE.html" tppabs="http://www.python.org/doc/current/lib/module-DEVICE.html">18.9 DEVICE  </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -