Example #1
0
void Application::mainLoop()
{
	const ptime currentTime = microsec_clock::local_time();
	mLastTimeErisPollStart = currentTime;
	mLastTimeErisPollEnd = currentTime;
	mLastTimeInputProcessingStart = currentTime;
	mLastTimeInputProcessingEnd = currentTime;
	mLastTimeMainLoopStepEnded = currentTime;
	DesiredFpsListener desiredFpsListener;
	while (mShouldQuit == false) {
		mainLoopStep(desiredFpsListener.getMicrosecondsPerFrame());
	}
}
Example #2
0
void Application::mainLoop()
{
	DesiredFpsListener desiredFpsListener;
	Eris::EventService& eventService = mSession->getEventService();
	Input& input(Input::getSingleton());

	do {
		try {
			Log::sCurrentFrameStartMilliseconds = microsec_clock::local_time();

			unsigned int frameActionMask = 0;
			TimeFrame timeFrame = TimeFrame(boost::posix_time::microseconds(desiredFpsListener.getMicrosecondsPerFrame()));
			bool updatedRendering = mOgreView->renderOneFrame(timeFrame);
			if (updatedRendering) {
				frameActionMask |= MainLoopController::FA_GRAPHICS;
				frameActionMask |= MainLoopController::FA_INPUT;
			} else {
				input.processInput();
				frameActionMask |= MainLoopController::FA_INPUT;
			}

			if (mWorldView) {
				mWorldView->update();
			}

			mServices->getSoundService().cycle();
			frameActionMask |= MainLoopController::FA_SOUND;

			//Keep on running IO and handlers until we need to render again
			eventService.processEvents(timeFrame.getRemainingTime(), mShouldQuit);

			mMainLoopController.EventFrameProcessed(timeFrame, frameActionMask);

		} catch (const std::exception& ex) {
			S_LOG_CRITICAL("Got exception, shutting down." << ex);
			throw;
		} catch (...) {
			S_LOG_CRITICAL("Got unknown exception, shutting down.");
			throw;
		}

	} while (!mShouldQuit);
}