Loading...
Searching...
No Matches
OgreBites::ApplicationContextBase Class Reference
Optional Components » Bites

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

`#include <OgreApplicationContextBase.h>`

Inheritance diagram for OgreBites::ApplicationContextBase:
[legend]

## Public Member Functions

| ApplicationContextBase (const Ogre::String &appName="Ogre3D")
virtual | ~ApplicationContextBase ()
void | _fireInputEvent (const Event &event, uint32_t windowID) const
| inspect the event and call one of the corresponding functions on the registered InputListener
void | addInputListener (InputListener *lis)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
virtual void | addInputListener (NativeWindowType *win, InputListener *lis)
| attach input listener
void | closeApp ()
| This function closes down the application - saves the configuration then shutdowns.
void | createDummyScene ()
| Creates dummy scene to allow rendering GUI in viewport.
virtual void | createRoot ()
| Creates the OGRE root.
virtual NativeWindowPair | createWindow (const Ogre::String &name, uint32_t w=0, uint32_t h=0, Ogre::NameValuePairList miscParams=Ogre::NameValuePairList())
| Create a new render window.
void | destroyDummyScene ()
| Destroys dummy scene.
void | destroyRTShaderSystem ()
| Destroy the RT Shader system.
void | destroyWindow (const Ogre::String &name)
| destroy and erase an NativeWindowPair by name
void | enableShaderCache () const
| enables the caching of compiled shaders to file
bool | frameEnded (const Ogre::FrameEvent &evt) override
| Called just after a frame has been rendered.
bool | frameRenderingQueued (const Ogre::FrameEvent &evt) override
| Called after all render targets have had their rendering commands issued, but before render windows have been asked to flip their buffers over.
bool | frameStarted (const Ogre::FrameEvent &evt) override
| Called when a frame is about to begin rendering.
virtual float | getDisplayDPI () const
| get the vertical DPI of the display
Ogre::FileSystemLayer & | getFSLayer () const
| get the FileSystemLayer instance pointing to an application specific directory
InputListener * | getImGuiInputListener () const
Ogre::OverlaySystem * | getOverlaySystem () const
Ogre::RenderWindow * | getRenderWindow () const
| get the main RenderWindow owns the context on OpenGL
Ogre::Root * | getRoot () const
void | initApp ()
| This function initializes the render system and resources.
Ogre::ImGuiOverlay * | initialiseImGui ()
| Set up the overlay system for usage with ImGui.
bool | initialiseRTShaderSystem ()
| Initialize the RT Shader system.
virtual void | loadResources ()
| Loads context-wide resource groups.
virtual void | locateResources ()
| Finds context-wide resource groups.
virtual bool | oneTimeConfig ()
| Configures the startup settings for OGRE.
virtual void | pollEvents ()
| process all window events since last call
void | reconfigure (const Ogre::String &renderer, Ogre::NameValuePairList &options)
void | removeInputListener (InputListener *lis)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
virtual void | removeInputListener (NativeWindowType *win, InputListener *lis)
| detatch input listener
void | runRenderingSettingsDialog ()
| Show the renderer configuration menu.
void | setRTSSWriteShadersToDisk (bool write)
| make the RTSS write out the generated shaders for caching and debugging
virtual void | setup ()
| Sets up the context after configuration.
void | setWindowGrab (bool grab=true)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
virtual void | setWindowGrab (NativeWindowType *win, bool grab=true)
| When input is grabbed the mouse is confined to the window.
virtual void | shutdown ()
| Cleans up and shuts down the context.
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)
Public Member Functions inherited from Ogre::FrameListener
virtual | ~FrameListener ()

## Static Public Member Functions

static Ogre::String | getDefaultMediaDir ()
| the directory where the media files were installed

## Detailed Description

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

Subclass to implement specific event callbacks.

## Constructor & Destructor Documentation

## ApplicationContextBase()

OgreBites::ApplicationContextBase::ApplicationContextBase | ( | const Ogre::String & | appName = "Ogre3D" | ) |

explicit

Referenced by OgreBites::ApplicationContextQt::ApplicationContextQt().

## ~ApplicationContextBase()

virtual OgreBites::ApplicationContextBase::~ApplicationContextBase | ( |  | ) |

virtual

## Member Function Documentation

## getRenderWindow()

Ogre::RenderWindow * OgreBites::ApplicationContextBase::getRenderWindow | ( |  | ) | const

inline

get the main RenderWindow owns the context on OpenGL

## getRoot()

Ogre::Root * OgreBites::ApplicationContextBase::getRoot | ( |  | ) | const

inline

## getOverlaySystem()

Ogre::OverlaySystem * OgreBites::ApplicationContextBase::getOverlaySystem | ( |  | ) | const

inline

## initApp()

void OgreBites::ApplicationContextBase::initApp | ( |  | ) |

This function initializes the render system and resources.

## closeApp()

void OgreBites::ApplicationContextBase::closeApp | ( |  | ) |

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

## frameStarted()

bool OgreBites::ApplicationContextBase::frameStarted | ( | const Ogre::FrameEvent & | evt | ) |

inline override virtual

Called when a frame is about to begin rendering.

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.

References pollEvents().

## frameRenderingQueued()

bool OgreBites::ApplicationContextBase::frameRenderingQueued | ( | const Ogre::FrameEvent & | evt | ) |

override virtual

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

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()

bool OgreBites::ApplicationContextBase::frameEnded | ( | const Ogre::FrameEvent & | evt | ) |

inline override virtual

Called just after a frame has been rendered.

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::ApplicationContextBase::windowMoved | ( | Ogre::RenderWindow * | rw | ) |

inline virtual

## windowResized()

virtual void OgreBites::ApplicationContextBase::windowResized | ( | Ogre::RenderWindow * | rw | ) |

inline virtual

## windowClosing()

virtual bool OgreBites::ApplicationContextBase::windowClosing | ( | Ogre::RenderWindow * | rw | ) |

inline virtual

## windowClosed()

virtual void OgreBites::ApplicationContextBase::windowClosed | ( | Ogre::RenderWindow * | rw | ) |

inline virtual

## windowFocusChange()

virtual void OgreBites::ApplicationContextBase::windowFocusChange | ( | Ogre::RenderWindow * | rw | ) |

inline virtual

## _fireInputEvent()

void OgreBites::ApplicationContextBase::_fireInputEvent | ( | const Event & | event,
|  | uint32_t | windowID ) const

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

Parameters

  event | Input Event
  windowID | only call listeners of this window

## initialiseRTShaderSystem()

bool OgreBites::ApplicationContextBase::initialiseRTShaderSystem | ( |  | ) |

Initialize the RT Shader system.

## setRTSSWriteShadersToDisk()

void OgreBites::ApplicationContextBase::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 | Whether to write out the generated shaders

## destroyRTShaderSystem()

void OgreBites::ApplicationContextBase::destroyRTShaderSystem | ( |  | ) |

Destroy the RT Shader system.

## setup()

virtual void OgreBites::ApplicationContextBase::setup | ( |  | ) |

virtual

Sets up the context after configuration.

## createRoot()

virtual void OgreBites::ApplicationContextBase::createRoot | ( |  | ) |

virtual

Creates the OGRE root.

## oneTimeConfig()

virtual bool OgreBites::ApplicationContextBase::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.

## setWindowGrab() [1/2]

virtual void OgreBites::ApplicationContextBase::setWindowGrab | ( | NativeWindowType * | win,
|  | bool | grab = true )

inline virtual

When input is grabbed the mouse is confined to the window.

Reimplemented in OgreBites::ApplicationContextQt.

Referenced by setWindowGrab().

## getDisplayDPI()

virtual float OgreBites::ApplicationContextBase::getDisplayDPI | ( |  | ) | const

inline virtual

get the vertical DPI of the display

## setWindowGrab() [2/2]

void OgreBites::ApplicationContextBase::setWindowGrab | ( | bool | grab = true | ) |

inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References OgreAssert, and setWindowGrab().

## locateResources()

virtual void OgreBites::ApplicationContextBase::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::ApplicationContextBase::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()

void OgreBites::ApplicationContextBase::reconfigure | ( | const Ogre::String & | renderer,
|  | Ogre::NameValuePairList & | options )

Deprecated
  use do not use

## shutdown()

virtual void OgreBites::ApplicationContextBase::shutdown | ( |  | ) |

virtual

Cleans up and shuts down the context.

Reimplemented in OgreBites::ApplicationContextQt.

## pollEvents()

virtual void OgreBites::ApplicationContextBase::pollEvents | ( |  | ) |

virtual

process all window events since last call

Reimplemented in OgreBites::ApplicationContextQt.

Referenced by frameStarted().

## createDummyScene()

void OgreBites::ApplicationContextBase::createDummyScene | ( |  | ) |

Creates dummy scene to allow rendering GUI in viewport.

## destroyDummyScene()

void OgreBites::ApplicationContextBase::destroyDummyScene | ( |  | ) |

Destroys dummy scene.

## runRenderingSettingsDialog()

void OgreBites::ApplicationContextBase::runRenderingSettingsDialog | ( |  | ) |

Show the renderer configuration menu.

creates a dummy scene to allow rendering the dialog

## enableShaderCache()

void OgreBites::ApplicationContextBase::enableShaderCache | ( |  | ) | const

enables the caching of compiled shaders to file

also loads any existing cache

## addInputListener() [1/2]

virtual void OgreBites::ApplicationContextBase::addInputListener | ( | NativeWindowType * | win,
|  | InputListener * | lis )

virtual

attach input listener

Parameters

  lis | the listener
  win | the window to receive the events for.

Reimplemented in OgreBites::ApplicationContextQt.

Referenced by addInputListener(), and OgreBites::ApplicationContextQt::setWindowGrab().

## addInputListener() [2/2]

void OgreBites::ApplicationContextBase::addInputListener | ( | InputListener * | lis | ) |

inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References addInputListener(), and OgreAssert.

## removeInputListener() [1/2]

virtual void OgreBites::ApplicationContextBase::removeInputListener | ( | NativeWindowType * | win,
|  | InputListener * | lis )

virtual

detatch input listener

Parameters

  lis | the listener
  win | the window to receive the events for.

Reimplemented in OgreBites::ApplicationContextQt.

Referenced by removeInputListener(), and OgreBites::ApplicationContextQt::setWindowGrab().

## removeInputListener() [2/2]

void OgreBites::ApplicationContextBase::removeInputListener | ( | InputListener * | lis | ) |

inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References OgreAssert, and removeInputListener().

## createWindow()

virtual NativeWindowPair OgreBites::ApplicationContextBase::createWindow | ( | const Ogre::String & | name,
|  | uint32_t | w = 0,
|  | uint32_t | h = 0,
|  | Ogre::NameValuePairList | miscParams = Ogre::NameValuePairList() )

virtual

Create a new render window.

You must use SDL and not an auto-created window as SDL does not get the events otherwise.

By default the values from ogre.cfg are used for w, h and miscParams.

Reimplemented in OgreBites::ApplicationContextQt.

## destroyWindow()

void OgreBites::ApplicationContextBase::destroyWindow | ( | const Ogre::String & | name | ) |

destroy and erase an NativeWindowPair by name

## getFSLayer()

Ogre::FileSystemLayer & OgreBites::ApplicationContextBase::getFSLayer | ( |  | ) | const

inline

get the FileSystemLayer instance pointing to an application specific directory

## getDefaultMediaDir()

Ogre::String OgreBites::ApplicationContextBase::getDefaultMediaDir | ( |  | ) |

static

the directory where the media files were installed

same as OGRE_MEDIA_DIR in CMake

## initialiseImGui()

Ogre::ImGuiOverlay * OgreBites::ApplicationContextBase::initialiseImGui | ( |  | ) |

Set up the overlay system for usage with ImGui.

## getImGuiInputListener()

InputListener * OgreBites::ApplicationContextBase::getImGuiInputListener | ( |  | ) | const

inline

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

- OgreApplicationContextBase.h