| OpenGLContext: A Learning Environment for PyOpenGL |
|---|---|
|
OpenGLContext provides you with an
environment for learning OpenGL programming. It gives you an
object-oriented Python-friendly set of services which let you
concentrate on your OpenGL code instead of the underlying GUI
environment.
|
|
Installation |
OpenGLContext is dependent on having at least the 2.0 release of PyOpenGL. PyOpenGL and OpenGLContext can be downloaded from the PyOpenGL project. OpenGLContext uses many of the OpenGL 1.1 features, and provides a GLUT 3.7 context, so you'll want to be sure you have those. You will need to install Numeric Python (version 19+ if possible), and the Python Imaging Library. Once you have these dependencies installed, you can install the OpenGLContext package. OpenGLContext is distributed as a distutils-enabled
Python extension archive. Setup consists of unpacking the .zip
archive into a temporary directory and running |
Structural Overview of OpenGLContext |
Within the top-level OpenGLContext package are the objects
implementing the Context
interface. Each supported GUI library defines a derived
Context class which overrides various methods to support the Context API
(these derived classes are named GLUTContext,
PyGameContext, wxContext, etceteras). Each
supported GUI will also provide a sub-class which uses the mix in
InteractiveContext, which, through the events package (see below), allows for
keyboard and mouse event processing. Each GUI library will then provide
a module Xtestingcontext.py (e.g. gluttestingcontext.py) which provides a context class factory function, and a "mainloop"
function. The testingcontext.py module then provides an interface for finding
the appropriate testing context for the specified GUI library.
Each Context class has a list of associated RenderMode objects, which implement the various rendering mode algorithms common in OpenGL. Currently there are Timer, Opaque, Transparent, and Select modes available, and all default Contexts include all four. On each visible rendering pass, the Opaque RenderMode creates a RenderPass object which stores pass-specific information such as the events needing selection processing and the "default" matrices for projections. The ViewPlatform and ViewPlatformMixin classes provide a simple navigation interface using the keyboard arrow keys (walk/fly) and the ALT-arrow keys (pan/slide). These classes make use of the Trackball, ExamineManager and DragWatcher classes as well. Finally, at the top-level, we have a number of utility functions and modules, including drawcube (a testing function), Quaternion, utilities, vector utilities, and triangle utilities. The scenegraph and scenegraph.text packages provide a set of Python classes which render certain common types of geometry, materials, textures and grouping nodes (modeled loosely after VRML 97 nodes). This allows you to create "retained mode" scenes for rendering in your contexts (note that these classes are largely divorced from the internals of the context). You'll find Transform (including integer "names" reported during selection), Shape, Material, ImageTexture, and Light nodes which are similar to their VRML 97 namesakes. The ArrayGeometry class handles the rendering of all of IndexedFaceSet, IndexedLineSet and PointSet, with the modules of those names simply instantiating ArrayGeometry instances with the appropriate parameters. The text package is just a placeholder until PyOpenGL adds text support (which it will hopefully do after the 2.0 release). The events package implements a simple cross GUI-library event generation and handling system. Each GUI library defines subclasses of the major event and event handler classes. These subclasses translate from native events to OpenGLContext events. The event handler classes (which are mixin classes) are then included in the GUI library's Context class to provide the event handling interfaces. |
Introductory Documentation |
|
Reference Documentation |
|
| A SourceForge Open-Source
Project: |
|