next up previous contents
Next: Displayable Up: Display objects Previous: DispCmd   Contents

Subsections


DisplayDevice

Files: DisplayDevice.h, DisplayDevice.C
Derived from: \bf ColorUser
Global instance (if any): display
Used in optional component: Part of main VMD code

Description

DisplayDevice is one of the main classes in VMD. It is a base class for all the objects which are responsible for drawing the current scene, either to an on-screen graphics window, or to a file. It is also responsible for encapsulating the window-manager-specific routines which are different for each type of windowing environment (e.g., X-Windows-based window management and OpenGL rendering, etc.). Finally, it is used to determine which item a pointer is currently selecting when a pointer button is pressed, either by a 2D mouse or by a 3D pointer. There are a large number of virtual functions which each subclass may define (if relevant). The DisplayDevice base class provides default versions for all the virtual functions, however, so that by default a bare DisplayDevice acts as an ``empty'' device, which essentially does nothing but which still functions to the rest of the program as a working DisplayDevice.

The main DisplayDevice instance used by VMD is also responsible for checking for and reporting window events, such as when the window is resized, or when a mouse button is pressed, etc. The main graphics window has one main popup menu (which could be implemented as a pulldown menu if required), which the DisplayDevice must be able to create and acquire events from.

There are two types of subclasses of DisplayDevice used in VMD:

Constructors

Enumerations, lists or character name arrays

Internal data structures

Virtual member functions

Method of use

Once a DisplayDevice has been defined, and an instance created, a simple sequence of routines are used to have the device render a scene. This sequence is implemented by the void Scene::draw(DisplayDevice *display) routine. A Scene object maintains a list of display lists and Displayable objects which create those lists (see section 24.7). The draw routine uses the DisplayDevice as follows:
  1. display->prepare3D()
  2. Set the stereo mode to the left eye, or just normal, using the command display->left() or display->normal()
  3. For each Displayable in the Scene, the prepare routine is called to make that object ready to be drawn.
  4. For each display list maintained by the Scene, the command display->render(displist) is called.
  5. If the display is in stereo, display->right() is called and the previous step repeated.
  6. display->update()

Drawing to a file instead of the screen is almost identical, with the following exceptions:

Suggestions for future changes/additions

Most of the intended future improvements previously listed here have already been completed.


next up previous contents
Next: Displayable Up: Display objects Previous: DispCmd   Contents
vmd@ks.uiuc.edu