Chapter 4. Writing Applications

Table of Contents

Application Review
Basic Application Information
Draw Manager-Specific Application Classes
Getting Input
How to Get Input
Where to Get Input
Tutorial: Getting Input
OpenGL Applications
OpenGL Drawing: vjGlApp::draw()
Tutorial: Drawing a Cube with OpenGL
Context-Specific Data
Using Context-Specific Data
Context-Specific Data Details
Tutorial: Drawing a Cube using OpenGL Display Lists
OpenGL Performer Applications
Scene Graph Initialization: vjPfApp::initScene()
Scene Graph Access: vjPfApp::getScene()
Tutorial: Loading a Model with OpenGL Performer
Other vjPfApp Methods
VTK Applications

This chapter alone comprises the bulk of information about application development. Each section outlines one area of interest for application developers. For example, there are chapters that show how to get input from the system and chapters that show how to write applications for each of the currently supported graphics APIs. Please note that when writing an application, there will be overlap between these sections. For example, an application that needs input, sound, and OpenGL graphics will be based on concepts from each of the relevant sections.

Application Review

Before getting into too much detail, we present this section as a review from earlier chapters. There is no new information here; it is simply a quick overview of the basics of VR Juggler applications.

Basic Application Information

As described in previous chapters (see Chapter 1, for example), all VR Juggler applications derive from a base application object class (vjApp). This class defines the basic interface that VR Juggler expects from all application objects. This means that when constructing an application, the user-defined application object must inherit from vjApp or from a Draw Manager-specific application class that has vjApp as a superclass. For example:

class userApp : public vjApp
{
public:
   init();
   preFrame();
   postFrame();
}

This defines a new application class (userApp), instances of which can be used anywhere that VR Juggler expects an application object.

Draw Manager-Specific Application Classes

A user application does not have to (and in most cases does not) derive from vjApp. In most cases, an application class is derived from a Draw Manager-specific application class. For example:

class userGlApp : public vjGlApp
{
public:
   init();
   preFrame();
   postFrame();
   
   draw();
}

This is an example of an OpenGL application. The application class (userGlApp) has derived directly from the OpenGL Draw Manager-specific vjGlApp application base class. This class provides extra definitions in the interface that are custom for OpenGL applications.