From 225530c69013f458a7eabf543fd3b93ccd0c94ec Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Fri, 10 Aug 2012 23:19:12 +0400 Subject: [PATCH] implemented better main loop for OS X (carbon version). Input feels far less laggy --- libs/openengine/ogre/renderer.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 70bbf7940..3096e2e6e 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -17,6 +17,10 @@ #include #include +#if defined(__APPLE__) && !__LP64__ +#include +#endif + using namespace Ogre; using namespace OEngine::Render; @@ -31,7 +35,33 @@ void OgreRenderer::cleanup() void OgreRenderer::start() { +#if defined(__APPLE__) && !defined(__LP64__) + bool quit = false; + // OSX Carbon Message Pump + do { + EventRef event = NULL; + EventTargetRef targetWindow; + targetWindow = GetEventDispatcherTarget(); + + // If we are unable to get the target then we no longer care about events. + if (!targetWindow) return; + + // Grab the next event while possible + while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &event) == noErr) + { + // Dispatch the event + SendEventToEventTarget(event, targetWindow); + ReleaseEvent(event); + } + + if (!Ogre::Root::getSingleton().renderOneFrame()) { + quit = true; + } + + } while (!quit); +#else mRoot->startRendering(); +#endif } bool OgreRenderer::loadPlugins() const