Removed a workaround from Renderer, some cleanup

pull/136/head
scrawl 11 years ago
parent c2bbbef637
commit 4f35fd8184

@ -503,7 +503,8 @@ void OMW::Engine::go()
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript); MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
// Start the main rendering loop // Start the main rendering loop
mOgre->start(); while (!mEnvironment.getRequestExit())
Ogre::Root::getSingleton().renderOneFrame();
// Save user settings // Save user settings
settings.saveUser(settingspath); settings.saveUser(settingspath);

@ -13,6 +13,7 @@
#include "windowmanager.hpp" #include "windowmanager.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment *MWBase::Environment::sThis = 0;
bool MWBase::Environment::sExit = false;
MWBase::Environment::Environment() MWBase::Environment::Environment()
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),

@ -32,6 +32,8 @@ namespace MWBase
InputManager *mInputManager; InputManager *mInputManager;
float mFrameDuration; float mFrameDuration;
static bool sExit;
Environment (const Environment&); Environment (const Environment&);
///< not implemented ///< not implemented
@ -44,6 +46,9 @@ namespace MWBase
~Environment(); ~Environment();
static void setRequestExit () { sExit = true; }
static bool getRequestExit () { return sExit; }
void setWorld (World *world); void setWorld (World *world);
void setSoundManager (SoundManager *soundManager); void setSoundManager (SoundManager *soundManager);

@ -77,7 +77,7 @@ namespace MWGui
else if (sender == mButtons["options"]) else if (sender == mButtons["options"])
MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings); MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings);
else if (sender == mButtons["exitgame"]) else if (sender == mButtons["exitgame"])
Ogre::Root::getSingleton ().queueEndRendering (); MWBase::Environment::get().setRequestExit();
else if (sender == mButtons["newgame"]) else if (sender == mButtons["newgame"])
{ {
MWBase::Environment::get().getWorld()->startNewGame(); MWBase::Environment::get().getWorld()->startNewGame();

@ -182,9 +182,6 @@ namespace MWInput
case A_GameMenu: case A_GameMenu:
toggleMainMenu (); toggleMainMenu ();
break; break;
case A_Quit:
exitNow();
break;
case A_Screenshot: case A_Screenshot:
screenshot(); screenshot();
break; break;
@ -814,13 +811,6 @@ namespace MWInput
mAlwaysRunActive = !mAlwaysRunActive; 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() void InputManager::resetIdleTime()
{ {
if (mTimeIdle < 0) if (mTimeIdle < 0)

@ -177,7 +177,6 @@ namespace MWInput
void activate(); void activate();
void toggleWalking(); void toggleWalking();
void toggleAutoMove(); void toggleAutoMove();
void exitNow();
void rest(); void rest();
void quickKey (int index); void quickKey (int index);
@ -194,7 +193,7 @@ namespace MWInput
A_GameMenu, A_GameMenu,
A_Quit, // Exit the program A_Unused,
A_Screenshot, // Take a screenshot A_Screenshot, // Take a screenshot

@ -28,21 +28,6 @@ using namespace Ogre;
using namespace OEngine::Render; 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() void OgreRenderer::cleanup()
{ {
delete mFader; delete mFader;
@ -60,23 +45,6 @@ void OgreRenderer::cleanup()
unloadPlugins(); 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() void OgreRenderer::loadPlugins()
{ {
#ifdef ENABLE_PLUGIN_GL #ifdef ENABLE_PLUGIN_GL
@ -158,20 +126,15 @@ void OgreRenderer::configure(const std::string &logPath,
// Set up logging first // Set up logging first
new LogManager; new LogManager;
Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log")); Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));
logging = _logging;
if(logging) if(_logging)
// Full log detail // Full log detail
log->setLogDetail(LL_BOREME); log->setLogDetail(LL_BOREME);
else else
// Disable logging // Disable logging
log->setDebugOutputEnabled(false); log->setDebugOutputEnabled(false);
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
mRoot = new CustomRoot("", "", "");
#else
mRoot = new Root("", "", ""); 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) #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
loadPlugins(); loadPlugins();

@ -27,18 +27,13 @@
#include "OgreTexture.h" #include "OgreTexture.h"
#include <OgreWindowEventUtilities.h> #include <OgreWindowEventUtilities.h>
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include <OgreRoot.h>
#endif
struct SDL_Window; struct SDL_Window;
struct SDL_Surface; struct SDL_Surface;
namespace Ogre namespace Ogre
{ {
#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE
class Root; class Root;
#endif
class RenderWindow; class RenderWindow;
class SceneManager; class SceneManager;
class Camera; class Camera;
@ -61,17 +56,6 @@ namespace OEngine
std::string icon; 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 Fader;
class WindowSizeListener class WindowSizeListener
@ -82,11 +66,7 @@ namespace OEngine
class OgreRenderer class OgreRenderer
{ {
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
CustomRoot *mRoot;
#else
Ogre::Root *mRoot; Ogre::Root *mRoot;
#endif
Ogre::RenderWindow *mWindow; Ogre::RenderWindow *mWindow;
SDL_Window *mSDLWindow; SDL_Window *mSDLWindow;
Ogre::SceneManager *mScene; Ogre::SceneManager *mScene;
@ -110,7 +90,6 @@ namespace OEngine
Fader* mFader; Fader* mFader;
std::vector<Ogre::ParticleEmitterFactory*> mEmitterFactories; std::vector<Ogre::ParticleEmitterFactory*> mEmitterFactories;
std::vector<Ogre::ParticleAffectorFactory*> mAffectorFactories; std::vector<Ogre::ParticleAffectorFactory*> mAffectorFactories;
bool logging;
WindowSizeListener* mWindowListener; WindowSizeListener* mWindowListener;
@ -139,7 +118,6 @@ namespace OEngine
, mD3D9Plugin(NULL) , mD3D9Plugin(NULL)
#endif #endif
, mFader(NULL) , mFader(NULL)
, logging(false)
{ {
} }
@ -167,9 +145,6 @@ namespace OEngine
/// Kill the renderer. /// Kill the renderer.
void cleanup(); void cleanup();
/// Start the main rendering loop
void start();
void loadPlugins(); void loadPlugins();
void unloadPlugins(); void unloadPlugins();

Loading…
Cancel
Save