Table of Contents
In this chapter, we give some methods for porting an application written with the CAVElib™ software to VR Juggler. We explain the process for an OpenGL application. Throughout, we compare and contrast the techniques used by VR Juggler and the CAVElib™ software, and we translate concepts familiar to CAVElib™ programmers into VR Juggler terms.
In the CAVElib™, the initialize, draw, and frame routines are known as callbacks implemented with C function pointers. In VR juggler, the equivalent routines are “called back” using an application object. An application object is a C++ class that defines methods to encapsulate the functionality of the application within a single C++ object.
The following lists the draw, frame, and initialize routines used in the CAVElib™ software.
Draw: An application's display callback function is defined by passing a function pointer to CAVEDisplay()
Frame: The frame function is defined with CAVEFrameFunction()
Init: The initialization callback is defined using CAVEInitApplication()
With VR Juggler, no C function pointers are necessary, but a pointer to an application object must be given to the VR Juggler kernel. As described in earlier sections of this chapter, the first step is to derive a new application class from vrj::GlApp. For more information on application objects, it may be helpful to review Chapter 2, Application Basics. Briefly, the application class definition would appear similar to the following:
class MyApplication : public vrj::GlApp
{
...
};The draw, frame, and initialize routine concepts in VR Juggler are presented in the following list.
Draw: An application's display “callback” function is defined by a member function called draw() in the derived class. This is where OpenGL rendering commands such as glBegin(), glVertex(), etc. are placed.
Frame: Calculations such as navigation, collision, physics, artificial intelligence, etc. are often placed in the frame function. The frame function is split across three member functions:
MyApplication::preFrame(), called before draw()
MyApplication::intraFrame(), called during draw()
MyApplication::postFrame(), called after draw()
Init: There is an initialization member function for data and an initialization member function for creating context-specific data (display lists, texture objects). The latter is called for each display context in the system. These two member functions are:
MyApplication::init(), called once per application startup
MyApplication::contextInit(), called once per display context creation
Readers who find some of these concepts unfamiliar are encouraged to read the section called “OpenGL Applications”. For information about context-specific data, refer to the section called “Context-Specific Data”.