Osiris Framework  0.3
OApplication Class Referenceabstract

The Osiris Application base class. More...

#include <OsirisSDK/OApplication.h>

Public Member Functions

 OApplication (const char *title, int argc, char **argv, int windowPos_x=OAPPLICATION_DEFAULT_POSX, int windowPos_y=OAPPLICATION_DEFAULT_POSY, int windowWidth=OAPPLICATION_DEFAULT_WIDTH, int windowHeight=OAPPLICATION_DEFAULT_HEIGHT, int targetFPS=OAPPLICATION_DEFAULT_TARGETFPS, int simulationStep_us=OAPPLICATION_DEFAULT_SIMULATIONSTEP)
 Class constructor. More...
 
virtual ~OApplication ()
 Class destructor.
 
OCameracamera ()
 Returns the application camera object. More...
 
int windowWidth () const
 Returns the window width in pixels.
 
int windowHeight () const
 Returns the window height in pixels.
 
int targetFPS () const
 Returns the target frames-per-second. More...
 
int simulationStep () const
 Returns the simulation step in microseconds.
 
void setTargetFPS (int targetFPS)
 Sets the target frames-per-second.
 
void setSimulationStep (int simulationStep)
 Sets the simulation step. More...
 
void addEventRecipient (OEvent::EventType eventType, OObject *recipient)
 Adds an OObject class object as event recipient for given type. More...
 
void removeEventRecipient (OEvent::EventType eventType, OObject *recipient)
 Removes an OObject class object as event recipient for given type. More...
 
void start ()
 Initializes the application and starts the main loop.
 
void scheduleDelete (OObject *obj)
 Schedule an object for deletion at the end of the current loop.
 
const OStats< float > & fpsStats () const
 Frames-per-second statistics.
 
const OStats< int > & idleTimeStats () const
 Simulation idle time statistics (in case target FPS is set) in microseconds.
 
const OStats< int > & renderTimeStats () const
 Renderization time statistics in microseconds.
 
const OStats< float > & performanceStats () const
 Performance coefficient statistics. More...
 

Static Public Member Functions

static OApplicationactiveInstance ()
 Returns active OApplication instance.
 

Protected Member Functions

virtual void init ()=0
 Method called prior to entering the main loop to initialize the OApplication object.
 
virtual void clearScreen ()
 Called in the begining of the render process for each loop to clear the previous screen.
 
int eventRecipientCount (OEvent::EventType type)
 Returns the number of event recipients for a given event type.
 
void queueEvent (OEvent *evt)
 Queue event to be processed by the application and the subscribed OOBject class objects.
 
void processEvents ()
 Process event queue.
 
void deleteObjects ()
 Remove objects previously scheduled for deletion.
 
virtual void update (const OTimeIndex &timeIndex)=0
 Method called on each simulation iteration.
 
virtual void render ()=0
 Renderization method.
 

Detailed Description

The Osiris Application base class.

This is the class that represents an application based on the Osiris Framework. It handles basic interaction with OpenGL, creating the window and handling main loop.

Constructor & Destructor Documentation

OApplication::OApplication ( const char *  title,
int  argc,
char **  argv,
int  windowPos_x = OAPPLICATION_DEFAULT_POSX,
int  windowPos_y = OAPPLICATION_DEFAULT_POSY,
int  windowWidth = OAPPLICATION_DEFAULT_WIDTH,
int  windowHeight = OAPPLICATION_DEFAULT_HEIGHT,
int  targetFPS = OAPPLICATION_DEFAULT_TARGETFPS,
int  simulationStep_us = OAPPLICATION_DEFAULT_SIMULATIONSTEP 
)

Class constructor.

The constructor creates the window and initializes OpenGL.

Parameters
titleApplication window title.
argcNumber of command line arguments
argvCommand line arguments.
windowPos_xWindow position on the X axis.
windowPos_yWindow position on the Y axis.
windowWidthWindow width.
windowHeightWindow height.
targetFPSTarget FPS.
simulationStep_usSimulation step in microseconds.

Member Function Documentation

void OApplication::addEventRecipient ( OEvent::EventType  eventType,
OObject recipient 
)

Adds an OObject class object as event recipient for given type.

Parameters
eventTypeEvent type.
recipientObject that will receive the events.
OCamera * OApplication::camera ( )

Returns the application camera object.

Returns
Pointer to the application camera object.
const OStats< float > & OApplication::performanceStats ( ) const

Performance coefficient statistics.

The performance coefficient is the reason between the time it takes to process a simulation iteration and the time step. The closest it is to zero the better. If it is greater than 1, the simulation will face problems catching up to real time, which means that either the simulation step is too short, or that the iteration processing is taking too long and must be optimized.

void OApplication::removeEventRecipient ( OEvent::EventType  eventType,
OObject recipient 
)

Removes an OObject class object as event recipient for given type.

Parameters
eventTypeEvent type.
recipientObject that will receive the events.
void OApplication::setSimulationStep ( int  simulationStep)

Sets the simulation step.

This parameter must be set with caution. It shouldn't be neither too large (the simulation will be sloppy) or too short (it should be at least the time it takes to process the simulation iteration).

Parameters
simulationStepThe desired simulation step in microseconds.
int OApplication::targetFPS ( ) const

Returns the target frames-per-second.

Parameters
Thedesired FPS. If zero, the screen rendering will not be limited.

The documentation for this class was generated from the following files: