diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 848cc1c719..d93cc50c36 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -2,6 +2,11 @@ #include #include +#include +#include +#include + + #include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" @@ -18,10 +23,37 @@ namespace MWGui { getWidget(mLoadingText, "LoadingText"); getWidget(mProgressBar, "ProgressBar"); + getWidget(mBackgroundImage, "BackgroundImage"); + + + mBackgroundMaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + mBackgroundMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); + mBackgroundMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); + mBackgroundMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(""); + + mRectangle = new Ogre::Rectangle2D(true); + mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0); + mRectangle->setMaterial("BackgroundMaterial"); + // Render the background before everything else + mRectangle->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY-1); + // Use infinite AAB to always stay visible + Ogre::AxisAlignedBox aabInf; + aabInf.setInfinite(); + mRectangle->setBoundingBox(aabInf); + // Attach background to the scene + Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(); + node->attachObject(mRectangle); + mRectangle->setVisible(false); } LoadingScreen::~LoadingScreen() { + delete mRectangle; + } + + void LoadingScreen::onResChange(int w, int h) + { + setCoord(0,0,w,h); } void LoadingScreen::setLoadingProgress (const std::string& stage, int depth, int current, int total) @@ -87,7 +119,7 @@ namespace MWGui // SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work. for (int i = 0; i < Ogre::RENDER_QUEUE_MAX; ++i) { - if (i > 0 && i < 90) + if (i > 0 && i < 96) mSceneMgr->addSpecialCaseRenderQueue(i); } mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE); @@ -96,9 +128,38 @@ namespace MWGui // (e.g. when using "coc" console command, it would enter an infinite loop and crash due to overflow) MWBase::Environment::get().getInputManager()->update(0, true); - mWindow->getViewport(0)->setClearEveryFrame(false); + Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(mWindow->getViewport(0)); + + bool hasCompositor = chain->getCompositor ("gbufferFinalizer"); + + + if (!hasCompositor) + { + mWindow->getViewport(0)->setClearEveryFrame(false); + } + else + { + mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); + mRectangle->setVisible(true); + + for (unsigned int i = 0; igetNumCompositors(); ++i) + { + Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), false); + } + } + mWindow->update(); - mWindow->getViewport(0)->setClearEveryFrame(true); + + if (!hasCompositor) + mWindow->getViewport(0)->setClearEveryFrame(true); + else + { + for (unsigned int i = 0; igetNumCompositors(); ++i) + { + Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true); + } + mRectangle->setVisible(false); + } // resume 3d rendering mSceneMgr->clearSpecialCaseRenderQueues(); diff --git a/apps/openmw/mwgui/loadingscreen.hpp b/apps/openmw/mwgui/loadingscreen.hpp index 2256bca6b1..abd59db499 100644 --- a/apps/openmw/mwgui/loadingscreen.hpp +++ b/apps/openmw/mwgui/loadingscreen.hpp @@ -8,7 +8,6 @@ namespace MWGui { - class LoadingScreen : public WindowBase { public: @@ -17,6 +16,8 @@ namespace MWGui void setLoadingProgress (const std::string& stage, int depth, int current, int total); + void onResChange(int w, int h); + private: Ogre::SceneManager* mSceneMgr; Ogre::RenderWindow* mWindow; @@ -26,6 +27,7 @@ namespace MWGui MyGUI::TextBox* mLoadingText; MyGUI::ProgressBar* mProgressBar; + MyGUI::ImageBox* mBackgroundImage; int mCurrentCellLoading; int mTotalCellsLoading; @@ -33,6 +35,9 @@ namespace MWGui int mTotalRefsLoading; int mCurrentRefList; + Ogre::Rectangle2D* mRectangle; + Ogre::MaterialPtr mBackgroundMaterial; + bool mLoadingOn; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 196e898b09..8d12950a0b 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -149,7 +149,7 @@ WindowManager::WindowManager( mQuickKeysMenu = new QuickKeysMenu(*this); mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this); - mLoadingScreen->setCoord (0,0,w,h); + mLoadingScreen->onResChange (w,h); mInputBlocker = mGui->createWidget("",0,0,w,h,MyGUI::Align::Default,"Windows",""); @@ -684,7 +684,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector mBookWindow->center(); mQuickKeysMenu->center(); mSpellBuyingWindow->center(); - mLoadingScreen->setCoord (0,0,x,y); + mLoadingScreen->onResChange (x,y); mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y)); mInputBlocker->setSize(MyGUI::IntSize(x,y)); } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index e983353cb0..70d7de5529 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -734,6 +734,7 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec sh::Factory::getInstance ().setGlobalSetting ("mrt_output", useMRT() ? "true" : "false"); sh::Factory::getInstance ().setGlobalSetting ("simple_water", Settings::Manager::getBool("shader", "Water") ? "false" : "true"); mObjects.rebuildStaticGeometry (); + mRendering.getViewport ()->setClearEveryFrame (true); } else if (it->second == "underwater effect" && it->first == "Water") { diff --git a/files/mygui/openmw_loading_screen.layout b/files/mygui/openmw_loading_screen.layout index 7096115f63..6862702ca1 100644 --- a/files/mygui/openmw_loading_screen.layout +++ b/files/mygui/openmw_loading_screen.layout @@ -4,13 +4,17 @@ - + - - + + + + + + + + - -