Using the code from before we are going to add our own FrameListener
implementation
MyFrameListener
exposing three publicly visible event handler functions:class MyFrameListener : public Ogre::FrameListener { public:
frameStarted
function, which for now returns false
to close the application:bool frameStarted(const Ogre::FrameEvent& evt) { return false; }
frameEnded
function, which also returns false:
bool frameEnded(const Ogre::FrameEvent& evt) { return false; }
frameRenderingQueued
function, which also returns false:
bool frameRenderingQueued(const Ogre::FrameEvent& evt) { return false; }
FrameListener:
MyFrameListener* _listener;
NULL:
_listener = NULL;
delete _listener;
FrameListener
and add it to the root object; this should happen in the startup()
function:_listener = new MyFrameListener(); _root->addFrameListener(_listener);
We created our own FrameListener
class, which didn't rely on the ExampleFrameListener
implementation. This time we inherited directly from the FrameListener
interface. This interface consists of three virtual functions, which we implemented. We already knew the frameStarted
function, but the other two are new. All three functions return false
, which is an indicator to Ogre 3D to stop rendering and close the application. Using our implementation, we added a FrameListener
to the root
instance and started the application; not surprisingly, it closed directly.
18.222.155.187