vrj::App Class Reference

Encapsulates the actual application. More...

#include <vrj/Kernel/App.h>

Inheritance diagram for vrj::App:

Inheritance graph
[legend]
Collaboration diagram for vrj::App:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 App (Kernel *kern=NULL)
 Constructor.
virtual ~App ()
virtual void init ()
 Application initialization function.
virtual void apiInit ()
 Application graphics API initialization function.
virtual void exit ()
 Executes any final clean-up needed for this application before exiting.
virtual void preFrame ()
 Executes any code needed to set up the application object state prior to rendering the scene.
virtual void latePreFrame ()
 Function called after preFrame() and application-specific data synchronization (in a cluster configuration) but before the start of a new frame.
virtual void intraFrame ()
 Function called during this application's drawing time.
virtual void postFrame ()
 Function called before updating input devices but after the frame rendering is complete.
virtual void reset ()
 Resets this application.
bool haveFocus ()
 Does this application currently have focus? If an application has focus, the user may be attempting to interact with it, so this application should process input.
virtual void focusChanged ()
 Called by the kernel when the focus state changes.
void setFocus (bool newState)
 Sets the focus state.
virtual float getDrawScaleFactor ()
 Returns the scale factor to convert from Juggler units (meters) to application units.
Default config handlers.
virtual bool configCanHandle (jccl::ConfigElementPtr element)
 Defaults to handling nothing.
virtual bool depSatisfied ()
 Are any application dependencies satisfied? If this application requires anything special of the system for successful initialization, check it here.
Factory functions
virtual DrawManagergetDrawManager ()=0
 Gets the Draw Manager to use.
virtual SoundManagergetSoundManager ()
 Get the SoundManager to use.

Public Attributes

KernelmKernel
 The Juggler kernel (here for convienence).
bool mHaveFocus
 The current focus state of this app object.

Protected Member Functions

virtual bool configAdd (jccl::ConfigElementPtr element)
 
Note:
Inherited from jccl::ConfigElementHandler.

virtual bool configRemove (jccl::ConfigElementPtr element)
 
Note:
Inherited from jccl::ConfigElementHandler.


Detailed Description

Encapsulates the actual application.

This defines the base class for all graphics API-specific application object types. The interface given is what the VR Juggler kernel expects in order to communicate with the application. Most of the application's interface will be defined in the derived graphics API-specific classes.

Users should write their application objectcs as subclasses of the graphics API-specific classes. Overriding the virtual functions in this class and in the graphics API-specific subclasses is the method by which the application programmer interfaces with VR Juggler.

The VR Juggler kernel control loop will look similar to this:

 while (drawing)
 {
    <b>app_obj->preFrame()</b>;
    <b>app_obj->latePreFrame()</b>;
    draw();
    <b>app_obj->intraFrame()</b>;
    sync();
    <b>app_obj->postFrame()</b>;

    updateAllDevices();
 }

Note:
One time through the loop is a "Juggler Frame."
See also:
vrj::Kernel

Definition at line 83 of file App.h.


Constructor & Destructor Documentation

vrj::App::App ( Kernel kern = NULL  ) 

Constructor.

Parameters:
kern The vrj::Kernel instance that is active (so that the application has easy access to the kernel). If NULL, defaults to value from vrj::Kernel::instance()

Definition at line 49 of file App.cpp.

References mKernel.

00050    : mKernel(kern)
00051    , mHaveFocus(true)
00052 {
00053    if(NULL == kern)
00054    {
00055       mKernel = Kernel::instance();
00056    }
00057 }

virtual vrj::App::~App (  )  [inline, virtual]

Definition at line 96 of file App.h.

00097    {
00098       /* Do nothing. */ ;
00099    }


Member Function Documentation

virtual void vrj::App::init (  )  [inline, virtual]

Application initialization function.

Execute any initialization needed before the grahpics API is started.

Note:
Derived classes must call the base class version of this method.

Reimplemented in vrj::OpenSGApp, and vrj::OsgApp.

Definition at line 110 of file App.h.

Referenced by vrj::OsgApp::init(), vrj::OpenSGApp::init(), and vrj::Kernel::startDrawManager().

00111    {;}

virtual void vrj::App::apiInit (  )  [inline, virtual]

Application graphics API initialization function.

Execute any initialization needed after the graphics API is started but before the Draw Manager starts the rendering loop(s).

Reimplemented in vrj::OpenSGApp.

Definition at line 118 of file App.h.

Referenced by vrj::Kernel::startDrawManager().

00119    {;}

virtual void vrj::App::exit (  )  [inline, virtual]

Executes any final clean-up needed for this application before exiting.

This is invoked by the kernel prior to this application object being removed from the kernel.

Reimplemented in vrj::OpenSGApp.

Definition at line 126 of file App.h.

00127    {;}

virtual void vrj::App::preFrame (  )  [inline, virtual]

Executes any code needed to set up the application object state prior to rendering the scene.

This is invoked by the kernel once per pass through the Juggler frame loop. This is called after input device updates but before the start of rendering a new frame of the scene.

Reimplemented in vrj::GlProcAppWrapper.

Definition at line 135 of file App.h.

Referenced by vrj::Kernel::controlLoop().

00136    {;}

virtual void vrj::App::latePreFrame (  )  [inline, virtual]

Function called after preFrame() and application-specific data synchronization (in a cluster configuration) but before the start of a new frame.

Note:
This is required because we cannot update data during the rendering process since it might be using multiple threads.

Reimplemented in vrj::OsgApp.

Definition at line 146 of file App.h.

Referenced by vrj::Kernel::controlLoop().

00147    {;}

virtual void vrj::App::intraFrame (  )  [inline, virtual]

Function called during this application's drawing time.

This can be used for "free" parallel processing, but it introduces a critical section to the code. If the rendering process is reading state data, this method should not be modifying any of that data. Instead, a double- or triple-buffering scheme must be used to allow parallel reading and writing of all application state used for rendering.

Reimplemented in vrj::GlProcAppWrapper.

Definition at line 157 of file App.h.

Referenced by vrj::Kernel::controlLoop().

00158    {;}

virtual void vrj::App::postFrame (  )  [inline, virtual]

Function called before updating input devices but after the frame rendering is complete.

Reimplemented in vrj::GlProcAppWrapper.

Definition at line 164 of file App.h.

Referenced by vrj::Kernel::controlLoop().

00165    {;}

virtual void vrj::App::reset (  )  [inline, virtual]

Resets this application.

This is used when the kernel (or applications) would like this application object to reset to its initial state. This is one of the only methods that can be safe for cross-calls from other application object interface methodss. That is, of course, as long as the override of this method is implemented in a safe manner. The override should be implemented such that it can be invoked at any time during the Juggler frame loop by the kernel or from a method such as preFrame() or postFrame() by the application object itself.

Definition at line 178 of file App.h.

00179    {;}

bool vrj::App::haveFocus (  )  [inline]

Does this application currently have focus? If an application has focus, the user may be attempting to interact with it, so this application should process input.

If not, the user is not interating with it, so ignore all input. However, the user may still be viewing it, so render, update any animations, etc. This is akin to the way a user can only interact with a GUI window that has focus.

Definition at line 189 of file App.h.

00190    {
00191       return mHaveFocus;
00192    }

virtual void vrj::App::focusChanged (  )  [inline, virtual]

Called by the kernel when the focus state changes.

Definition at line 195 of file App.h.

00196    {;}

void vrj::App::setFocus ( bool  newState  )  [inline]

Sets the focus state.

Postcondition:
If the focus state has changed, then focusChanged() is called.
Parameters:
newState A Boolean value indicating whether this application now has focus.
See also:
focusChanged()

Definition at line 208 of file App.h.

00209    {
00210       if(newState != mHaveFocus)
00211       {
00212          mHaveFocus = newState;
00213          this->focusChanged();
00214       }
00215    }

virtual float vrj::App::getDrawScaleFactor (  )  [inline, virtual]

Returns the scale factor to convert from Juggler units (meters) to application units.

Internally, VR Juggler stores and processes all position values in meters. The scale factor returned by this method is used by VR Juggler to scale the rendering state from meters to whatever units this application wants to use.

For example, to use feet as this application object's unit, return 3.28. Conversion constants can be found in the namespace gadget::PositionUnitConversion which is defined in the header file gadget/Type/Position/PositionUnitConversion.h from the Gadgeteer library.

Definition at line 230 of file App.h.

Referenced by vrj::PfDrawManager::updatePfProjections().

00231    {
00232       return gadget::PositionUnitConversion::ConvertToFeet;
00233    }

bool vrj::App::configCanHandle ( jccl::ConfigElementPtr  element  )  [virtual]

Defaults to handling nothing.

Note:
Inherited from jccl::ConfigElementHandler.

Definition at line 59 of file App.cpp.

00060 {
00061    boost::ignore_unused_variable_warning(element);
00062    return false;
00063 }

virtual bool vrj::App::depSatisfied (  )  [inline, virtual]

Are any application dependencies satisfied? If this application requires anything special of the system for successful initialization, check it here.

If the return value is false, then this application will not be started yet. If the return value is true, then this application will be allowed to enter the system.

Note:
Inherited from jccl::ConfigElementHandler.

Definition at line 255 of file App.h.

Referenced by vrj::Kernel::checkForReconfig().

00256    {
00257       return true;
00258    }

bool vrj::App::configAdd ( jccl::ConfigElementPtr  element  )  [protected, virtual]

Note:
Inherited from jccl::ConfigElementHandler.

Definition at line 65 of file App.cpp.

00066 {
00067    boost::ignore_unused_variable_warning(element);
00068    vprASSERT(false);
00069    return false;
00070 }

bool vrj::App::configRemove ( jccl::ConfigElementPtr  element  )  [protected, virtual]

Note:
Inherited from jccl::ConfigElementHandler.

Definition at line 72 of file App.cpp.

00073 {
00074    boost::ignore_unused_variable_warning(element);
00075    vprASSERT(false);
00076    return false;
00077 }

virtual DrawManager* vrj::App::getDrawManager (  )  [pure virtual]

Gets the Draw Manager to use.

Note:
Each derived app MUST implement this function.

Implemented in vrj::GlApp, and vrj::PfApp.

Referenced by vrj::Kernel::changeApplication().

SoundManager * vrj::App::getSoundManager (  )  [virtual]

Get the SoundManager to use.

Note:
Each derived app could implement this function if needed.

Definition at line 79 of file App.cpp.

References vrj::SoundManagerFactory::get().

Referenced by vrj::Kernel::changeApplication().

00080 {
00081    return &SoundManagerFactory::get();
00082 }


Member Data Documentation

Kernel* vrj::App::mKernel

The Juggler kernel (here for convienence).

Definition at line 269 of file App.h.

Referenced by App().

bool vrj::App::mHaveFocus

The current focus state of this app object.

Definition at line 270 of file App.h.


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:58:29 2007 for VR Juggler by  doxygen 1.5.1