diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index e1fd3a0af..7e344c4db 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -503,7 +503,8 @@ void OMW::Engine::go() MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript); // Start the main rendering loop - mOgre->start(); + while (!mEnvironment.getRequestExit()) + Ogre::Root::getSingleton().renderOneFrame(); // Save user settings settings.saveUser(settingspath); diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 5a13a50ec..6b309025c 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -13,6 +13,7 @@ #include "windowmanager.hpp" MWBase::Environment *MWBase::Environment::sThis = 0; +bool MWBase::Environment::sExit = false; MWBase::Environment::Environment() : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index a80e7ef87..466302907 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -32,6 +32,8 @@ namespace MWBase InputManager *mInputManager; float mFrameDuration; + static bool sExit; + Environment (const Environment&); ///< not implemented @@ -44,6 +46,9 @@ namespace MWBase ~Environment(); + static void setRequestExit () { sExit = true; } + static bool getRequestExit () { return sExit; } + void setWorld (World *world); void setSoundManager (SoundManager *soundManager); diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 1db6e9ecd..2c42dc210 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -77,7 +77,7 @@ namespace MWGui else if (sender == mButtons["options"]) MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings); else if (sender == mButtons["exitgame"]) - Ogre::Root::getSingleton ().queueEndRendering (); + MWBase::Environment::get().setRequestExit(); else if (sender == mButtons["newgame"]) { MWBase::Environment::get().getWorld()->startNewGame(); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 4746260ed..c4a360cd4 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -182,9 +182,6 @@ namespace MWInput case A_GameMenu: toggleMainMenu (); break; - case A_Quit: - exitNow(); - break; case A_Screenshot: screenshot(); break; @@ -814,13 +811,6 @@ namespace MWInput mAlwaysRunActive = !mAlwaysRunActive; } - // Exit program now button (which is disabled in GUI mode) - void InputManager::exitNow() - { - if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) - Ogre::Root::getSingleton().queueEndRendering (); - } - void InputManager::resetIdleTime() { if (mTimeIdle < 0) diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 5f9a752d7..b38c80e0e 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -177,7 +177,6 @@ namespace MWInput void activate(); void toggleWalking(); void toggleAutoMove(); - void exitNow(); void rest(); void quickKey (int index); @@ -194,7 +193,7 @@ namespace MWInput A_GameMenu, - A_Quit, // Exit the program + A_Unused, A_Screenshot, // Take a screenshot diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 912781240..d078e3c61 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -28,21 +28,6 @@ using namespace Ogre; using namespace OEngine::Render; -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - -CustomRoot::CustomRoot(const Ogre::String& pluginFileName, - const Ogre::String& configFileName, - const Ogre::String& logFileName) -: Ogre::Root(pluginFileName, configFileName, logFileName) -{} - -bool CustomRoot::isQueuedEnd() const -{ - return mQueuedEnd; -} - -#endif - void OgreRenderer::cleanup() { delete mFader; @@ -60,23 +45,6 @@ void OgreRenderer::cleanup() unloadPlugins(); } -void OgreRenderer::start() -{ -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - // we need this custom main loop because otherwise Ogre's Carbon message pump will - // steal input events even from our Cocoa window - // There's no way to disable Ogre's message pump other that comment pump code in Ogre's source - do { - if (!mRoot->renderOneFrame()) { - break; - } - - } while (!mRoot->isQueuedEnd()); -#else - mRoot->startRendering(); -#endif -} - void OgreRenderer::loadPlugins() { #ifdef ENABLE_PLUGIN_GL @@ -158,20 +126,15 @@ void OgreRenderer::configure(const std::string &logPath, // Set up logging first new LogManager; Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log")); - logging = _logging; - if(logging) + if(_logging) // Full log detail log->setLogDetail(LL_BOREME); else // Disable logging log->setDebugOutputEnabled(false); -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - mRoot = new CustomRoot("", "", ""); -#else mRoot = new Root("", "", ""); -#endif #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) loadPlugins(); diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index 89edc567d..c6a838805 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -27,18 +27,13 @@ #include "OgreTexture.h" #include -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE -#include -#endif struct SDL_Window; struct SDL_Surface; namespace Ogre { -#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE class Root; -#endif class RenderWindow; class SceneManager; class Camera; @@ -61,17 +56,6 @@ namespace OEngine std::string icon; }; -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - class CustomRoot : public Ogre::Root { - public: - bool isQueuedEnd() const; - - CustomRoot(const Ogre::String& pluginFileName = "plugins.cfg", - const Ogre::String& configFileName = "ogre.cfg", - const Ogre::String& logFileName = "Ogre.log"); - }; -#endif - class Fader; class WindowSizeListener @@ -82,11 +66,7 @@ namespace OEngine class OgreRenderer { -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - CustomRoot *mRoot; -#else Ogre::Root *mRoot; -#endif Ogre::RenderWindow *mWindow; SDL_Window *mSDLWindow; Ogre::SceneManager *mScene; @@ -110,7 +90,6 @@ namespace OEngine Fader* mFader; std::vector mEmitterFactories; std::vector mAffectorFactories; - bool logging; WindowSizeListener* mWindowListener; @@ -139,7 +118,6 @@ namespace OEngine , mD3D9Plugin(NULL) #endif , mFader(NULL) - , logging(false) { } @@ -167,9 +145,6 @@ namespace OEngine /// Kill the renderer. void cleanup(); - /// Start the main rendering loop - void start(); - void loadPlugins(); void unloadPlugins();