vrj::GlApp Class Reference

vrj::GlApp encapulates an actual OpenGL application object. More...

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

Inheritance diagram for vrj::GlApp:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GlApp (Kernel *kern=NULL)
virtual ~GlApp ()
virtual void draw ()=0
 Function that renders the scene.
virtual void contextInit ()
 Function that is called immediately after a new context is created.
virtual void contextClose ()
 Function that is called immediately before a context is closed.
virtual void contextPreDraw ()
 Function that is called upon entry into the context before rendering.
virtual void contextPostDraw ()
 Function that is called upon exit of the context after rendering.
virtual void bufferPreDraw ()
 Function that is called once for each frame buffer of an OpenGL context.
virtual void pipePreDraw ()
 Function that is called at the beginning of the drawing of each pipe.
Factory functions
virtual DrawManagergetDrawManager ()
 Get the DrawManager to use.

Detailed Description

vrj::GlApp encapulates an actual OpenGL application object.

This defines the base class from which OpenGL-based application classes should be derived. The interface given is what the kernel and the OpenGL Draw Manager expect in order to interact with the application.

The control loop will look similar to this:

 glapp_obj->contextInit();        // called for each context
 while (drawing)
 {
    glapp_obj->preFrame();
    glapp_obj->latePreFrame();
    glapp_obj->bufferPreDraw();   // called for each draw buffer
    glapp_obj->contextPreDraw();  // called for each context
    glapp_obj->draw();            // called for each viewport
    glapp_obj->contextPostDraw(); // called for each context
    glapp_obj->intraFrame();      // called in parallel to the draw functions
    sync();
    glapp_obj->postFrame();

    updateAllDevices();
 }

 glapp_obj->contextClose();       // called for each context

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

Definition at line 80 of file GlApp.h.


Constructor & Destructor Documentation

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

Definition at line 47 of file GlApp.cpp.

00047                          : App(kern)
00048 {
00049    /* Do nothing. */ ;
00050 }

vrj::GlApp::~GlApp (  )  [virtual]

Definition at line 53 of file GlApp.cpp.

00054 {
00055    /* Do nothing. */ ;
00056 }


Member Function Documentation

virtual void vrj::GlApp::draw (  )  [pure 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.

Implemented in vrj::GlProcAppWrapper, vrj::OpenSGApp, and vrj::OsgApp.

virtual void vrj::GlApp::contextInit (  )  [inline, 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 in vrj::GlProcAppWrapper, vrj::OpenSGApp, and vrj::OsgApp.

Definition at line 105 of file GlApp.h.

00106    {;}

virtual void vrj::GlApp::contextClose (  )  [inline, virtual]

Function that is called immediately before a context is closed.

Use this function to clean up any context-specific data structures.

Reimplemented in vrj::OsgApp.

Definition at line 112 of file GlApp.h.

00113    {;}

virtual void vrj::GlApp::contextPreDraw (  )  [inline, virtual]

Function that is called upon entry into the context before rendering.

This can be used to allocate context-specific data dynamically.

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 only once per context, per frame.
Note:
This function can be used for things that need to happen every frame but only once per context.

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

Definition at line 126 of file GlApp.h.

00127    {;}

virtual void vrj::GlApp::contextPostDraw (  )  [inline, virtual]

Function that is called upon exit of the context after rendering.

Precondition:
The OpenGL context has been set to the context for drawing.

Reimplemented in vrj::OpenSGApp.

Definition at line 134 of file GlApp.h.

00135    {;}

virtual void vrj::GlApp::bufferPreDraw (  )  [inline, 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 in vrj::GlProcAppWrapper, vrj::OpenSGApp, and vrj::OsgApp.

Definition at line 152 of file GlApp.h.

00153    {;}

virtual void vrj::GlApp::pipePreDraw (  )  [inline, virtual]

Function that is called at the beginning of the drawing of each pipe.

Precondition:
The library is preparing to render all windows on a given pipe.
Postcondition:
Any pre-pipe user calls have been done.
Note:
Currently the OpenGL context is not set when this function is called. This is a TEST function. USE AT YOUR OWN RISK!!!

Reimplemented in vrj::OsgApp.

Definition at line 164 of file GlApp.h.

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

00165    {;}

DrawManager * vrj::GlApp::getDrawManager (  )  [virtual]

Get the DrawManager to use.

Returns the OpenGL Draw Manager.

Implements vrj::App.

Definition at line 58 of file GlApp.cpp.

Referenced by vrj::OsgApp::draw(), and vrj::OpenSGApp::draw().

00059 {
00060    return GlDrawManager::instance();
00061 }


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