* The main loop. This just calls dispatchEvents(), update(), and draw()
* over and over again. The timing of the update and draw are decoupled.
* The actual frame rate is also calculated here. This function will return
- * with a value of 0 if the member variable running becomes true.
+ * the exit code used to stop the loop.
*/
int run()
nextStep += timestep;
}
+ if (ticksNow >= nextStep)
+ {
+ nextStep = ticksNow + timestep;
+ }
if (ticksNow >= nextDraw)
{
}
while (running);
- return 0;
+ return exitCode;
}
VideoPtr video;
bool running;
+ int exitCode;
Scalar timestep;
Scalar drawRate;
return impl_->run();
}
-void Engine::stop()
+void Engine::stop(int exitCode)
{
impl_->running = false;
+ impl_->exitCode = exitCode;
}