OGRE  1.10.5
Object-Oriented Graphics Rendering Engine
OgreBites::ApplicationContext Class Reference

Base class responsible for setting up a common context for applications. More...

#include <OgreApplicationContext.h>

+ Inheritance diagram for OgreBites::ApplicationContext:

Public Member Functions

 ApplicationContext (const Ogre::String &appName=OGRE_VERSION_NAME, bool grabInput=true)
 
virtual ~ApplicationContext ()
 
void _fireInputEvent (const Event &event) const
 inspect the event and call one of the corresponding functions on the registered InputListener More...
 
void addInputListener (InputListener *lis)
 attach input listener More...
 
void closeApp ()
 This function closes down the application - saves the configuration then shutdowns. More...
 
void createDummyScene ()
 Creates dummy scene to allow rendering GUI in viewport. More...
 
virtual void createRoot ()
 Creates the OGRE root. More...
 
void destroyDummyScene ()
 Destroys dummy scene. More...
 
void destroyRTShaderSystem ()
 Destroy the RT Shader system. More...
 
void enableShaderCache () const
 enables the caching of compiled shaders to file More...
 
virtual bool frameEnded (const Ogre::FrameEvent &evt)
 Called just after a frame has been rendered. More...
 
virtual bool frameRenderingQueued (const Ogre::FrameEvent &evt)
 Called after all render targets have had their rendering commands issued, but before render windows have been asked to flip their buffers over. More...
 
virtual bool frameStarted (const Ogre::FrameEvent &evt)
 Called when a frame is about to begin rendering. More...
 
Ogre::OverlaySystemgetOverlaySystem () const
 
Ogre::RenderWindowgetRenderWindow () const
 
Ogre::RootgetRoot () const
 
void initApp ()
 This function initializes the render system and resources. More...
 
bool initialiseRTShaderSystem ()
 Initialize the RT Shader system. More...
 
virtual void loadResources ()
 Loads context-wide resource groups. More...
 
virtual void locateResources ()
 Finds context-wide resource groups. More...
 
virtual bool oneTimeConfig ()
 Configures the startup settings for OGRE. More...
 
void pollEvents ()
 poll for any events for the main window More...
 
virtual void reconfigure (const Ogre::String &renderer, Ogre::NameValuePairList &options)
 Reconfigures the context. More...
 
void removeInputListener (InputListener *lis)
 detach input listener More...
 
void setRTSSWriteShadersToDisk (bool write)
 make the RTSS write out the generated shaders for caching and debugging More...
 
virtual void setup ()
 Sets up the context after configuration. More...
 
virtual void setupInput (bool grab)
 Sets up SDL input. More...
 
virtual void shutdown ()
 Cleans up and shuts down the context. More...
 
virtual void windowClosed (Ogre::RenderWindow *rw)
 
virtual bool windowClosing (Ogre::RenderWindow *rw)
 
virtual void windowFocusChange (Ogre::RenderWindow *rw)
 
virtual void windowMoved (Ogre::RenderWindow *rw)
 
virtual void windowResized (Ogre::RenderWindow *rw)
 

Detailed Description

Base class responsible for setting up a common context for applications.

Subclass to implement specific event callbacks.

Constructor & Destructor Documentation

◆ ApplicationContext()

OgreBites::ApplicationContext::ApplicationContext ( const Ogre::String appName = OGRE_VERSION_NAME,
bool  grabInput = true 
)
explicit

◆ ~ApplicationContext()

virtual OgreBites::ApplicationContext::~ApplicationContext ( )
virtual

Member Function Documentation

◆ getRenderWindow()

Ogre::RenderWindow* OgreBites::ApplicationContext::getRenderWindow ( ) const
inline

◆ getRoot()

Ogre::Root* OgreBites::ApplicationContext::getRoot ( ) const
inline

◆ getOverlaySystem()

Ogre::OverlaySystem* OgreBites::ApplicationContext::getOverlaySystem ( ) const
inline

◆ initApp()

void OgreBites::ApplicationContext::initApp ( )

This function initializes the render system and resources.

◆ closeApp()

void OgreBites::ApplicationContext::closeApp ( )

This function closes down the application - saves the configuration then shutdowns.

◆ frameStarted()

virtual bool OgreBites::ApplicationContext::frameStarted ( const Ogre::FrameEvent evt)
inlinevirtual

Called when a frame is about to begin rendering.

Remarks
This event happens before any render targets have begun updating.
Returns
True to go ahead, false to abort rendering and drop out of the rendering loop.

Reimplemented from Ogre::FrameListener.

◆ frameRenderingQueued()

virtual bool OgreBites::ApplicationContext::frameRenderingQueued ( const Ogre::FrameEvent evt)
virtual

Called after all render targets have had their rendering commands issued, but before render windows have been asked to flip their buffers over.

Remarks
The usefulness of this event comes from the fact that rendering commands are queued for the GPU to process. These can take a little while to finish, and so while that is happening the CPU can be doing useful things. Once the request to 'flip buffers' happens, the thread requesting it will block until the GPU is ready, which can waste CPU cycles. Therefore, it is often a good idea to use this callback to perform per-frame processing. Of course because the frame's rendering commands have already been issued, any changes you make will only take effect from the next frame, but in most cases that's not noticeable.
Returns
True to continue rendering, false to drop out of the rendering loop.

Reimplemented from Ogre::FrameListener.

◆ frameEnded()

virtual bool OgreBites::ApplicationContext::frameEnded ( const Ogre::FrameEvent evt)
inlinevirtual

Called just after a frame has been rendered.

Remarks
This event happens after all render targets have been fully updated and the buffers switched.
Returns
True to continue with the next frame, false to drop out of the rendering loop.

Reimplemented from Ogre::FrameListener.

◆ windowMoved()

virtual void OgreBites::ApplicationContext::windowMoved ( Ogre::RenderWindow rw)
inlinevirtual
Remarks
Window has moved position
Parameters
rwThe RenderWindow which created this events

Reimplemented from Ogre::WindowEventListener.

◆ windowResized()

virtual void OgreBites::ApplicationContext::windowResized ( Ogre::RenderWindow rw)
inlinevirtual
Remarks
Window has resized
Parameters
rwThe RenderWindow which created this events

Reimplemented from Ogre::WindowEventListener.

◆ windowClosing()

virtual bool OgreBites::ApplicationContext::windowClosing ( Ogre::RenderWindow rw)
inlinevirtual
Remarks
Window is closing (Only triggered if user pressed the [X] button)
Parameters
rwThe RenderWindow which created this events
Returns
True will close the window(default).

Reimplemented from Ogre::WindowEventListener.

◆ windowClosed()

virtual void OgreBites::ApplicationContext::windowClosed ( Ogre::RenderWindow rw)
inlinevirtual
Remarks
Window has been closed (Only triggered if user pressed the [X] button)
Parameters
rwThe RenderWindow which created this events
Note
The window has not actually close yet when this event triggers. It's only closed after all windowClosed events are triggered. This allows apps to deinitialise properly if they have services that needs the window to exist when deinitialising.

Reimplemented from Ogre::WindowEventListener.

◆ windowFocusChange()

virtual void OgreBites::ApplicationContext::windowFocusChange ( Ogre::RenderWindow rw)
inlinevirtual
Remarks
Window has lost/gained focus
Parameters
rwThe RenderWindow which created this events

Reimplemented from Ogre::WindowEventListener.

◆ _fireInputEvent()

void OgreBites::ApplicationContext::_fireInputEvent ( const Event event) const

inspect the event and call one of the corresponding functions on the registered InputListener

Parameters
eventInput Event

◆ initialiseRTShaderSystem()

bool OgreBites::ApplicationContext::initialiseRTShaderSystem ( )

Initialize the RT Shader system.

◆ setRTSSWriteShadersToDisk()

void OgreBites::ApplicationContext::setRTSSWriteShadersToDisk ( bool  write)

make the RTSS write out the generated shaders for caching and debugging

by default all shaders are generated to system memory. Must be called before loadResources

Parameters
write

◆ destroyRTShaderSystem()

void OgreBites::ApplicationContext::destroyRTShaderSystem ( )

Destroy the RT Shader system.

◆ setup()

virtual void OgreBites::ApplicationContext::setup ( )
virtual

Sets up the context after configuration.

◆ createRoot()

virtual void OgreBites::ApplicationContext::createRoot ( )
virtual

Creates the OGRE root.

◆ oneTimeConfig()

virtual bool OgreBites::ApplicationContext::oneTimeConfig ( )
virtual

Configures the startup settings for OGRE.

I use the config dialog here, but you can also restore from a config file. Note that this only happens when you start the context, and not when you reset it.

◆ setupInput()

virtual void OgreBites::ApplicationContext::setupInput ( bool  grab)
virtual

Sets up SDL input.

◆ locateResources()

virtual void OgreBites::ApplicationContext::locateResources ( )
virtual

Finds context-wide resource groups.

I load paths from a config file here, but you can choose your resource locations however you want.

◆ loadResources()

virtual void OgreBites::ApplicationContext::loadResources ( )
virtual

Loads context-wide resource groups.

I chose here to simply initialise all groups, but you can fully load specific ones if you wish.

◆ reconfigure()

virtual void OgreBites::ApplicationContext::reconfigure ( const Ogre::String renderer,
Ogre::NameValuePairList options 
)
virtual

Reconfigures the context.

Attempts to preserve the current sample state.

◆ shutdown()

virtual void OgreBites::ApplicationContext::shutdown ( )
virtual

Cleans up and shuts down the context.

◆ pollEvents()

void OgreBites::ApplicationContext::pollEvents ( )

poll for any events for the main window

◆ createDummyScene()

void OgreBites::ApplicationContext::createDummyScene ( )

Creates dummy scene to allow rendering GUI in viewport.

◆ destroyDummyScene()

void OgreBites::ApplicationContext::destroyDummyScene ( )

Destroys dummy scene.

◆ enableShaderCache()

void OgreBites::ApplicationContext::enableShaderCache ( ) const

enables the caching of compiled shaders to file

also loads any existing cache

◆ addInputListener()

void OgreBites::ApplicationContext::addInputListener ( InputListener lis)
inline

attach input listener

◆ removeInputListener()

void OgreBites::ApplicationContext::removeInputListener ( InputListener lis)
inline

detach input listener


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