diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 7698c3146..7dac03c34 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -314,9 +314,9 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) settings.getBool("minimize on focus loss", "Video") ? "1" : "0"); // not handling fullscreen yet, we should figure this out when adding SDL to the mix - mViewer.setUpViewInWindow(0, 0, settings.getInt("resolution x", "Video"), settings.getInt("resolution y", "Video"), settings.getInt("screen", "Video")); + mViewer->setUpViewInWindow(0, 0, settings.getInt("resolution x", "Video"), settings.getInt("resolution y", "Video"), settings.getInt("screen", "Video")); osg::ref_ptr rootNode (new osg::Group); - mViewer.setSceneData(rootNode); + mViewer->setSceneData(rootNode); mVFS.reset(new VFS::Manager(mFSStrict)); @@ -355,7 +355,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) std::string myguiResources = (mResDir / "mygui").string(); osg::ref_ptr guiRoot = new osg::Group; rootNode->addChild(guiRoot); - MWGui::WindowManager* window = new MWGui::WindowManager(&mViewer, guiRoot, mResourceSystem->getTextureManager(), + MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem->getTextureManager(), mCfgMgr.getLogPath().string() + std::string("/"), myguiResources, mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, mFallbackMap); mEnvironment.setWindowManager (window); @@ -371,7 +371,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) } // Create the world - mEnvironment.setWorld( new MWWorld::World (mViewer, rootNode, mResourceSystem.get(), + mEnvironment.setWorld( new MWWorld::World (*mViewer, rootNode, mResourceSystem.get(), mFileCollections, mContentFiles, mEncoder, mFallbackMap, mActivationDistanceOverride, mCellName, mStartupScript)); MWBase::Environment::get().getWorld()->setupPlayer(); @@ -433,7 +433,8 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) void OMW::Engine::go() { assert (!mContentFiles.empty()); - //assert (!mOgre); + + mViewer = new osgViewer::Viewer; Settings::Manager settings; std::string settingspath; @@ -474,12 +475,12 @@ void OMW::Engine::go() } // Start the main rendering loop - mViewer.setCameraManipulator(new osgGA::TrackballManipulator); - mViewer.addEventHandler(new osgViewer::StatsHandler); + mViewer->setCameraManipulator(new osgGA::TrackballManipulator); + mViewer->addEventHandler(new osgViewer::StatsHandler); - mViewer.realize(); + mViewer->realize(); osg::Timer frameTimer; - while (!mViewer.done()) + while (!mViewer->done()) { double dt = frameTimer.time_s(); frameTimer.setStartTick(); @@ -491,7 +492,7 @@ void OMW::Engine::go() MWBase::Environment::get().getWorld()->advanceTime( dt*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600); - mViewer.frame(/*simulationTime*/); + mViewer->frame(/*simulationTime*/); } // Save user settings diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 8c73920bd..be405c600 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -69,7 +69,7 @@ namespace OMW Files::PathContainer mDataDirs; std::vector mArchives; boost::filesystem::path mResDir; - osgViewer::Viewer mViewer; + osg::ref_ptr mViewer; std::string mCellName; std::vector mContentFiles; bool mVerboseScripts; diff --git a/apps/openmw/mwgui/myguirendermanager.cpp b/apps/openmw/mwgui/myguirendermanager.cpp index 53a194c73..55e78cb0c 100644 --- a/apps/openmw/mwgui/myguirendermanager.cpp +++ b/apps/openmw/mwgui/myguirendermanager.cpp @@ -561,7 +561,7 @@ void RenderManager::setViewSize(int width, int height) mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width); mInfo.pixScaleX = 1.0f / float(mViewSize.width); mInfo.pixScaleY = 1.0f / float(mViewSize.height); -std::cout << "setviewsize " << width << " " << height << std::endl; + onResizeView(mViewSize); mUpdate = true; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 63d74b355..86d065e39 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -173,8 +173,8 @@ namespace MWGui , mCurrentModals() , mFallbackMap(fallbackMap) { - Platform* platform = new Platform(viewer, guiRoot, textureManager); - platform->initialise(resourcePath, logpath); + mGuiPlatform = new Platform(viewer, guiRoot, textureManager); + mGuiPlatform->initialise(resourcePath, logpath); MyGUI::Gui* gui = new MyGUI::Gui; gui->initialise(""); @@ -411,6 +411,8 @@ namespace MWGui //delete mCursorManager; cleanupGarbage(); + + delete mGuiPlatform; } void WindowManager::cleanupGarbage() diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index a98fbf7b8..54b69be40 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -107,6 +107,8 @@ namespace MWGui class DebugWindow; class JailScreen; + class Platform; + class WindowManager : public MWBase::WindowManager { public: @@ -365,6 +367,8 @@ namespace MWGui virtual void cycleWeapon(bool next); private: + Platform* mGuiPlatform; + bool mConsoleOnlyScripts; std::map mTrackedWindows;