Table of Contents
In VR Juggler, all applications are written as objects that are handled by the kernel. The objects are known as application objects, and we will use that term frequently throughout this text. Application objects are introduced and explained in this chapter.
VR Juggler uses the application object to create the VR environment with which the users interact. The application object implements interfaces needed by the VR Juggler virtual platform.
Since VR Juggler applications are objects, developers do
not write the traditional main() function.
Instead, developers create an application object that
implements a set of pre-defined interfaces. The VR Juggler
kernel controls the application's processing time by calling
the object's interface implementation methods.
In traditional programs, the main()
function defines the point where the thread of control
enters the application. After the main()
function is called, the application starts performing any
necessary processing. When the operating system (OS) starts the
program, it gives the main() function some
unit of processing time. After the time unit (quantum) for the
process expires, the OS performs what is called a
“context switch” to change control to another
process. VR Juggler achieves similar functionality but in a
slightly different manner.
The application objects correspond to processes in a normal OS. The kernel is the scheduler, and it allocates time to an application by invoking the methods of the application object. Because the kernel has additional information about the resources needed by the applications, it maintains a very strict schedule to define when the application is granted processing time. This is the basis to maintain coherence across the system.
The first step in defining an application
object is to implement the basic interfaces defined by
the kernel and the Draw Managers. There is a base class for the interface that
the kernel expects (vrj::App) and a base class handled by each Draw Manager
interface (vrj::PfApp, vrj::GlApp, etc.). See Figure 2.1, “vrj::App hierarchy” for a visual
representation of the complete application interface hierarchy.
The interface defined in
vrj::App specifies methods for initialization, shutdown,
and execution of the application. This is the abstract type
that is seen by the VR Juggler kernel. The Draw Manager
interfaces specified in the vrj::*App
classes define the API-specific functions necessary to render
the virtual environment. For example, an interface used by a
Draw Manager could have functions for drawing the scene and for
initializing context-specific information.
To implement an application in VR Juggler, developers simply need to “fill in the blanks” of the appropriate interfaces. To simplify this process, there are default implementations of most methods in the interfaces. Hence, the user must only provide implementations for the aspects they want to customize. If an implementation is not provided in the user application object, the default is used, but it is important to know that in most cases, the default implementation does nothing.
When overriding a virtual method defined by a VR
Juggler application class, it is best to call the parent
class method implementation before performing any
application-specific processing. For example, if a
user-defined application object overrides
vrj::App::init() in the class
userApp, the method
userApp::init() should invoke
vrj::App::init() before performing
its own initialization steps.