Draw Manager-Specific Application Classes

Beyond the basic methods common to all applications, there are methods that are specific to a given Draw Manager. The application classes are extended for each of the specific Draw Managers. The graphics API-specific application classes derive from vrj::App and extend this interface further. They add extra “hooks” that support the abilities of the specific API.

OpenGL Application Class

The OpenGL application base class adds several methods to the application interface that allow rendering of OpenGL graphics. The extensions to the base vrj::App class are shown in Figure 2.4, “vrj::GlApp interface extensions to vrj::App”. In the following, we describe the method vrj::GlApp::draw(), the most important element of the interface. More details about the vrj::GlApp class are provided in the section called “OpenGL Applications”, found in Chapter 4, Writing Applications.

Figure 2.4. vrj::GlApp interface extensions to vrj::App

vrj::GlApp interface extensions to vrj::App

vrj::GlApp::draw()

The “draw function” is called by the OpenGL Draw Manager when it needs to render the current scene in an OpenGL graphics window. It is called for each active OpenGL context.

vrj::GlApp::getDrawScaleFactor()

As of VR Juggler 2.0 Alpha 1, applications can specify the units of measure that are the basis for the graphics they render. The default unit of measure is feet (identified by the constant scale factor gadget::PositionUnitConversion::ConvertToFeet) to maintain backwards compatibility with the previous VR Juggler semantics. By overriding this method, applications can identify the unit of measure they expect. The default implementation is the following:

float vrj::GlApp::getDrawScaleFactor()
{
   return gadget::PositionUnitConversion::ConvertToFeet;
}

Overriding this method means changing the rendering scale factor used by the OpenGL Draw Manager. The current list of constants (defined in gadget/Position/PositionUnitConversion.h) is as follows:

  • gadget::PositionUnitConversion::ConvertToFeet

  • gadget::PositionUnitConversion::ConvertToInches

  • gadget::PositionUnitConversion::ConvertToMeters

  • gadget::PositionUnitConversion::ConvertToCentimeters

Because the value returned is simply a scaling factor, user applications can define whatever units they want. Note that internally, VR Juggler is treating all units as meters, so the scaling factor converts from meters to the desired units.

OpenGL Performer Application Class

The OpenGL Performer application base class adds interface functions that deal with the OpenGL Performer scene graph. Some of the interface extensions are shown in Figure 2.5, “vrj::PfApp interface extensions to vrj::App”. The following is a description of only two methods in the vrj::PfApp interface. More detailed discussion on this class is provided in the section called “OpenGL Performer Applications”, found in Chapter 4, Writing Applications.

Figure 2.5. vrj::PfApp interface extensions to vrj::App

vrj::PfApp interface extensions to vrj::App

vrj::PfApp::initScene()

The initScene() member function is called when the application should create the scene graph it will use.

vrj::PfApp::getScene()

The getScene() member function is called by the Performer Draw Manager when it needs to know what scene graph it should render for the application.