vrj::GlProcAppWrapper Class Reference

Wrapper class used to allow procedural-style application programming. More...

#include <vrj/Draw/OGL/GlProcApp.h>

Inheritance diagram for vrj::GlProcAppWrapper:

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

Collaboration graph
[legend]
List of all members.

Public Types

typedef boost::function0<
void > 
callback_t

Public Member Functions

virtual void contextInit ()
 Function that is called immediately after a new context is created.
virtual void preFrame ()
 Executes any code needed to set up the application object state prior to rendering the scene.
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 bufferPreDraw ()
 Function that is called once for each frame buffer of an OpenGL context.
virtual void draw ()
 Function that renders the scene.
Getters and setters for the callback methods
void setDrawMethod (callback_t f)
void setContextInitMethod (callback_t f)
void setBufferPredrawMethod (callback_t f)
void setPreFrameMethod (callback_t f)
void setPostFrameMethod (callback_t f)
void setIntraFrameMethod (callback_t f)

Protected Member Functions

 GlProcAppWrapper ()
 Type for callbacks.
virtual ~GlProcAppWrapper ()
 vprSingletonHeader (GlProcAppWrapper)

Protected Attributes

callback_t mDrawMethod
callback_t mContextInit
callback_t mPreframeMethod
callback_t mPostframeMethod
callback_t mIntraframeMethod
callback_t mBufferPredrawMethod

Detailed Description

Wrapper class used to allow procedural-style application programming.

Callbacks are registered with this class using helper functions. Those callbacks are invoked indirectly by the VR Juggler kernel through the vrj::App and vrj::GlApp interface methods implemented in this class.

Definition at line 54 of file GlProcApp.h.


Member Typedef Documentation

typedef boost::function0<void> vrj::GlProcAppWrapper::callback_t

Definition at line 57 of file GlProcApp.h.


Constructor & Destructor Documentation

vrj::GlProcAppWrapper::GlProcAppWrapper (  )  [protected]

Type for callbacks.

Definition at line 44 of file GlProcApp.cpp.

00045    : vrj::GlApp()
00046 {
00047    ;
00048 }

vrj::GlProcAppWrapper::~GlProcAppWrapper (  )  [protected, virtual]

Definition at line 50 of file GlProcApp.cpp.

00051 {
00052    ;
00053 }


Member Function Documentation

vrj::GlProcAppWrapper::vprSingletonHeader ( GlProcAppWrapper   )  [protected]

void vrj::GlProcAppWrapper::setDrawMethod ( callback_t  f  )  [inline]

Definition at line 69 of file GlProcApp.h.

00070    {
00071       mDrawMethod = f;
00072    }

void vrj::GlProcAppWrapper::setContextInitMethod ( callback_t  f  )  [inline]

Definition at line 74 of file GlProcApp.h.

00075    {
00076       mContextInit = f;
00077    }

void vrj::GlProcAppWrapper::setBufferPredrawMethod ( callback_t  f  )  [inline]

Definition at line 79 of file GlProcApp.h.

00080    {
00081       mBufferPredrawMethod = f;
00082    }

void vrj::GlProcAppWrapper::setPreFrameMethod ( callback_t  f  )  [inline]

Definition at line 84 of file GlProcApp.h.

00085    {
00086       mPreframeMethod = f;
00087    }

void vrj::GlProcAppWrapper::setPostFrameMethod ( callback_t  f  )  [inline]

Definition at line 89 of file GlProcApp.h.

00090    {
00091       mPostframeMethod = f;
00092    }

void vrj::GlProcAppWrapper::setIntraFrameMethod ( callback_t  f  )  [inline]

Definition at line 94 of file GlProcApp.h.

00095    {
00096       mIntraframeMethod = f;
00097    }

void vrj::GlProcAppWrapper::contextInit (  )  [virtual]

Function that is called immediately after a new context is created.

Use this function to create context-specific data structures such as display lists and texture objects that are known to be required when the context is created.

Precondition:
The OpenGL context has been set to the new context.
Postcondition:
The application has completed context-specific initialization.

Reimplemented from vrj::GlApp.

Definition at line 55 of file GlProcApp.cpp.

References mContextInit.

00056 {
00057    if ( ! mContextInit.empty() )
00058    {
00059       mContextInit();
00060    }
00061 }

void vrj::GlProcAppWrapper::preFrame (  )  [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 from vrj::App.

Definition at line 63 of file GlProcApp.cpp.

References mPreframeMethod.

00064 {
00065    if ( ! mPreframeMethod.empty() )
00066    {
00067       mPreframeMethod();
00068    }
00069 }

void vrj::GlProcAppWrapper::intraFrame (  )  [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 from vrj::App.

Definition at line 71 of file GlProcApp.cpp.

References mIntraframeMethod.

00072 {
00073    if ( ! mIntraframeMethod.empty() )
00074    {
00075       mIntraframeMethod();
00076    }
00077 }

void vrj::GlProcAppWrapper::postFrame (  )  [virtual]

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

Reimplemented from vrj::App.

Definition at line 79 of file GlProcApp.cpp.

References mPostframeMethod.

00080 {
00081    if ( ! mPostframeMethod.empty() )
00082    {
00083       mPostframeMethod();
00084    }
00085 }

void vrj::GlProcAppWrapper::bufferPreDraw (  )  [virtual]

Function that is called once for each frame buffer of an OpenGL context.

This function is executed after contextInit() (if needed) but before contextPreDraw(). It is called once per frame buffer (see note).

Precondition:
The OpenGL context has been set to the context for drawing.
Postcondition:
The application object has executed any commands that need to be executed once per context, per buffer, per frame.
Note:
This function is designed to be used when some task must be performed only once per frame buffer (i.e., once for the left buffer, once for the right buffer). For example, the OpenGL clear color should be defined and glClear(GL_COLOR_BUFFER_BIT) should be called in this method.

Reimplemented from vrj::GlApp.

Definition at line 87 of file GlProcApp.cpp.

References mBufferPredrawMethod.

00088 {
00089    if ( ! mBufferPredrawMethod.empty() )
00090    {
00091       mBufferPredrawMethod();
00092    }
00093 }

void vrj::GlProcAppWrapper::draw (  )  [virtual]

Function that renders the scene.

Override this function with the user rendering routine.

Precondition:
OpenGL state has correct transformation and buffer selected.
Postcondition:
The current scene has been drawn.

Implements vrj::GlApp.

Definition at line 95 of file GlProcApp.cpp.

References mDrawMethod.

00096 {
00097    if ( ! mDrawMethod.empty() )
00098    {
00099       mDrawMethod();
00100    }
00101 }


Member Data Documentation

callback_t vrj::GlProcAppWrapper::mDrawMethod [protected]

Definition at line 113 of file GlProcApp.h.

Referenced by draw().

callback_t vrj::GlProcAppWrapper::mContextInit [protected]

Definition at line 114 of file GlProcApp.h.

Referenced by contextInit().

callback_t vrj::GlProcAppWrapper::mPreframeMethod [protected]

Definition at line 115 of file GlProcApp.h.

Referenced by preFrame().

callback_t vrj::GlProcAppWrapper::mPostframeMethod [protected]

Definition at line 116 of file GlProcApp.h.

Referenced by postFrame().

callback_t vrj::GlProcAppWrapper::mIntraframeMethod [protected]

Definition at line 117 of file GlProcApp.h.

Referenced by intraFrame().

callback_t vrj::GlProcAppWrapper::mBufferPredrawMethod [protected]

Definition at line 118 of file GlProcApp.h.

Referenced by bufferPreDraw().


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