Time for action — using our own rendering loop

Using the code from before we are now going to use our own rendering loop.

  1. Our application needs to know if it should keep running or not; add a Boolean as a private member of the application to remember the state:
    bool _keepRunning;
    
  2. Remove the startRendering function call in the startup function.
  3. Add a new function called renderOneFrame, which calls the renderOneFrame function of the root instance and saves the return value in the _keepRunning member variable. Before this call, add a function to process all window events:
    void renderOneFrame()
    {
    Ogre::WindowEventUtilities::messagePump();
    _keepRunning = _root->renderOneFrame();
    }
    
  4. Add a getter for the _keepRunning member variable:
    bool keepRunning() { return ...

Get Ogre 3D 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.