Using the code from before we are now going to use our own rendering loop.
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;
Remove the
startRendering
function call in thestartup
function.Add a new function called
renderOneFrame
, which calls therenderOneFrame
function of theroot
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(); }
Add a getter for the
_keepRunning
member variable:bool keepRunning() { return _keepRunning; }
Add a
while
loop to the main function, which keeps running as long as thekeepRunning
function returnstrue
. In the body of the loop, call therenderOneFrame
function of the application.while(app.keepRunning()) { app.renderOneFrame...