OpenGLContext Structural Overview

The OpenGLContext Package (top-level)

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 (e.g. which provides a context class factory function, and a "mainloop" function. The module then provides an interface for finding the appropriate testing context for the specified GUI library.

Context classes are registered via SetupTools entry_points in the script.  You can register context classes for your GUI library and produce a .egg file which will plug into OpenGLContext.

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.

Scenegraph Rendering

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 provides basic text rendering in 3D or 2D forms using TTFQuery or one of the GUI library engines.

Events and Selection

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.