OGRE  master
Object-Oriented Graphics Rendering Engine
OgreBites::ApplicationContextQt Class Reference

Specialization for connecting with Qt. More...

#include <OgreApplicationContextQt.h>

+ Inheritance diagram for OgreBites::ApplicationContextQt:

Public Member Functions

 ApplicationContextQt (const Ogre::String &appName="Ogre3D")
 
void _fireInputEvent (const Event &event, uint32_t windowID) const
 inspect the event and call one of the corresponding functions on the registered InputListener More...
 
void addInputListener (NativeWindowType *win, InputListener *lis) override
 attach input listener More...
 
void addInputListener (InputListener *lis)
 
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...
 
NativeWindowPair createWindow (const Ogre::String &name, uint32_t w=0, uint32_t h=0, Ogre::NameValuePairList miscParams=Ogre::NameValuePairList()) override
 Create a new render window. More...
 
NativeWindowPair createWindow (QWindow *window, Ogre::NameValuePairList miscParams=Ogre::NameValuePairList())
 
void destroyDummyScene ()
 Destroys dummy scene. More...
 
void destroyRTShaderSystem ()
 Destroy the RT Shader system. More...
 
void destroyWindow (const Ogre::String &name)
 destroy and erase an NativeWindowPair by name 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::FileSystemLayergetFSLayer ()
 get the FileSystemLayer instace pointing to an application specific directory More...
 
Ogre::OverlaySystemgetOverlaySystem () const
 
Ogre::RenderWindowgetRenderWindow () const
 get the main RenderWindow owns the context on OpenGL More...
 
Ogre::RootgetRoot () const
 
void initApp ()
 This function initializes the render system and resources. More...
 
bool initialiseRTShaderSystem ()
 Initialize the RT Shader system. More...
 
void injectMainWindow (QWindow *window)
 allows overriding the main (first) Window with a pre-created QWindow 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 () override
 process all window events since last call More...
 
virtual void reconfigure (const Ogre::String &renderer, Ogre::NameValuePairList &options)
 Reconfigures the context. More...
 
void removeInputListener (NativeWindowType *win, InputListener *lis) override
 detatch input listener More...
 
void removeInputListener (InputListener *lis)
 
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...
 
void setWindowGrab (NativeWindowType *win, bool grab)
 When input is grabbed the mouse is confined to the window. More...
 
void setWindowGrab (bool grab=true)
 
void shutdown () override
 Cleans up and shuts down the context. More...
 
void useQtEventLoop (bool enable)
 signal that you want to use the Qt event loop 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)
 

Static Public Member Functions

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

Detailed Description

Specialization for connecting with Qt.

  • Set a QBasicTimer on this or call startTimer() to update all associated windows using Root::renderOneFrame.
  • Use the QWindow::requestUpdate() slot to refresh a single Window using RenderWindow::update
  • QWidget::createWindowContainer and QWidget::windowHandle() provide translation between QWidget and QWindow

Assumes that Ogre Main loop is used for compatibility with other implementations.

Constructor & Destructor Documentation

§ ApplicationContextQt()

OgreBites::ApplicationContextQt::ApplicationContextQt ( const Ogre::String appName = "Ogre3D")
inlineexplicit

Member Function Documentation

§ createWindow() [1/2]

NativeWindowPair OgreBites::ApplicationContextQt::createWindow ( const Ogre::String name,
uint32_t  w = 0,
uint32_t  h = 0,
Ogre::NameValuePairList  miscParams = Ogre::NameValuePairList() 
)
overridevirtual

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

§ createWindow() [2/2]

NativeWindowPair OgreBites::ApplicationContextQt::createWindow ( QWindow *  window,
Ogre::NameValuePairList  miscParams = Ogre::NameValuePairList() 
)

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

§ injectMainWindow()

void OgreBites::ApplicationContextQt::injectMainWindow ( QWindow *  window)
inline

allows overriding the main (first) Window with a pre-created QWindow

Parameters
window

References OgreAssert.

§ useQtEventLoop()

void OgreBites::ApplicationContextQt::useQtEventLoop ( bool  enable)
inline

signal that you want to use the Qt event loop

aka QApplication::exec() instead of Root::startRendering. In this case you may want to call startTimer on this QObject which ensures that Root::renderOneFrame is called periodically.

Parameters
enable

References OgreBites::ApplicationContextBase::addInputListener(), OgreBites::ApplicationContextBase::removeInputListener(), and OgreBites::ApplicationContextBase::setWindowGrab().

§ setWindowGrab() [1/2]

void OgreBites::ApplicationContextQt::setWindowGrab ( NativeWindowType win,
bool  grab 
)
virtual

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

Reimplemented from OgreBites::ApplicationContextBase.

§ addInputListener() [1/2]

void OgreBites::ApplicationContextQt::addInputListener ( NativeWindowType win,
InputListener lis 
)
overridevirtual

attach input listener

Parameters
listhe listener
winthe window to receive the events for.

Reimplemented from OgreBites::ApplicationContextBase.

§ removeInputListener() [1/2]

void OgreBites::ApplicationContextQt::removeInputListener ( NativeWindowType win,
InputListener lis 
)
overridevirtual

detatch input listener

Parameters
listhe listener
winthe window to receive the events for.

Reimplemented from OgreBites::ApplicationContextBase.

§ pollEvents()

void OgreBites::ApplicationContextQt::pollEvents ( )
overridevirtual

process all window events since last call

Reimplemented from OgreBites::ApplicationContextBase.

§ shutdown()

void OgreBites::ApplicationContextQt::shutdown ( )
overridevirtual

Cleans up and shuts down the context.

Reimplemented from OgreBites::ApplicationContextBase.

§ getRenderWindow()

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

get the main RenderWindow owns the context on OpenGL

§ getRoot()

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

§ getOverlaySystem()

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

§ initApp()

void OgreBites::ApplicationContextBase::initApp ( )
inherited

This function initializes the render system and resources.

§ closeApp()

void OgreBites::ApplicationContextBase::closeApp ( )
inherited

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

§ frameStarted()

virtual bool OgreBites::ApplicationContextBase::frameStarted ( const Ogre::FrameEvent evt)
inlinevirtualinherited

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::ApplicationContextBase::frameRenderingQueued ( const Ogre::FrameEvent evt)
virtualinherited

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::ApplicationContextBase::frameEnded ( const Ogre::FrameEvent evt)
inlinevirtualinherited

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

§ windowResized()

virtual void OgreBites::ApplicationContextBase::windowResized ( Ogre::RenderWindow rw)
inlinevirtualinherited

§ windowClosing()

virtual bool OgreBites::ApplicationContextBase::windowClosing ( Ogre::RenderWindow rw)
inlinevirtualinherited

§ windowClosed()

virtual void OgreBites::ApplicationContextBase::windowClosed ( Ogre::RenderWindow rw)
inlinevirtualinherited

§ windowFocusChange()

virtual void OgreBites::ApplicationContextBase::windowFocusChange ( Ogre::RenderWindow rw)
inlinevirtualinherited

§ _fireInputEvent()

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

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

Parameters
eventInput Event
windowIDonly call listeners of this window

§ initialiseRTShaderSystem()

bool OgreBites::ApplicationContextBase::initialiseRTShaderSystem ( )
inherited

Initialize the RT Shader system.

§ setRTSSWriteShadersToDisk()

void OgreBites::ApplicationContextBase::setRTSSWriteShadersToDisk ( bool  write)
inherited

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::ApplicationContextBase::destroyRTShaderSystem ( )
inherited

Destroy the RT Shader system.

§ setup()

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

Sets up the context after configuration.

§ createRoot()

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

Creates the OGRE root.

§ oneTimeConfig()

virtual bool OgreBites::ApplicationContextBase::oneTimeConfig ( )
virtualinherited

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() [2/2]

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

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

References OgreAssert.

§ locateResources()

virtual void OgreBites::ApplicationContextBase::locateResources ( )
virtualinherited

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

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::ApplicationContextBase::reconfigure ( const Ogre::String renderer,
Ogre::NameValuePairList options 
)
virtualinherited

Reconfigures the context.

Attempts to preserve the current sample state.

§ createDummyScene()

void OgreBites::ApplicationContextBase::createDummyScene ( )
inherited

Creates dummy scene to allow rendering GUI in viewport.

§ destroyDummyScene()

void OgreBites::ApplicationContextBase::destroyDummyScene ( )
inherited

Destroys dummy scene.

§ enableShaderCache()

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

enables the caching of compiled shaders to file

also loads any existing cache

§ addInputListener() [2/2]

void OgreBites::ApplicationContextBase::addInputListener ( InputListener lis)
inlineinherited

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

References OgreAssert.

§ removeInputListener() [2/2]

void OgreBites::ApplicationContextBase::removeInputListener ( InputListener lis)
inlineinherited

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

References OgreAssert.

§ destroyWindow()

void OgreBites::ApplicationContextBase::destroyWindow ( const Ogre::String name)
inherited

destroy and erase an NativeWindowPair by name

§ getFSLayer()

Ogre::FileSystemLayer& OgreBites::ApplicationContextBase::getFSLayer ( )
inlineinherited

get the FileSystemLayer instace pointing to an application specific directory

§ getDefaultMediaDir()

static Ogre::String OgreBites::ApplicationContextBase::getDefaultMediaDir ( )
staticinherited

the directory where the media files were installed

same as OGRE_MEDIA_DIR in CMake


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