From 96a87b582c41f2c83a373a019a776a5ec16f1b6e Mon Sep 17 00:00:00 2001 From: psi29a Date: Thu, 17 Dec 2020 22:51:04 +0000 Subject: [PATCH] Merge branch 'loadingScreen_initialdrawcallback' into 'master' Fix for !472 for older versions of OSG See merge request OpenMW/openmw!474 (cherry picked from commit 35e25d79b9a6c76807084be5ca2584c4fd9b9c35) 4447dd41 osg versions 06f4d63b Preserve callback in older osg version --- apps/openmw/mwgui/loadingscreen.cpp | 14 ++++++++++++++ apps/openmw/mwgui/loadingscreen.hpp | 2 ++ 2 files changed, 16 insertions(+) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 20586ef4af..9ab5e32a3f 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -43,6 +44,7 @@ namespace MWGui , mNestedLoadingCount(0) , mProgress(0) , mShowWallpaper(true) + , mOldCallback(nullptr) { mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize()); @@ -322,7 +324,13 @@ namespace MWGui mCopyFramebufferToTextureCallback = new CopyFramebufferToTextureCallback(mTexture); } +#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 10) mViewer->getCamera()->addInitialDrawCallback(mCopyFramebufferToTextureCallback); +#else + // TODO: Remove once we officially end support for OSG versions pre 3.5.10 + mOldCallback = mViewer->getCamera()->getInitialDrawCallback(); + mViewer->getCamera()->setInitialDrawCallback(mCopyFramebufferToTextureCallback); +#endif mBackgroundImage->setBackgroundImage(""); mBackgroundImage->setVisible(false); @@ -367,7 +375,13 @@ namespace MWGui if (mCopyFramebufferToTextureCallback) { + +#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 10) mViewer->getCamera()->removeInitialDrawCallback(mCopyFramebufferToTextureCallback); +#else + // TODO: Remove once we officially end support for OSG versions pre 3.5.10 + mViewer->getCamera()->setInitialDrawCallback(mOldCallback); +#endif mCopyFramebufferToTextureCallback = nullptr; } diff --git a/apps/openmw/mwgui/loadingscreen.hpp b/apps/openmw/mwgui/loadingscreen.hpp index ac911ab60b..d58899eae4 100644 --- a/apps/openmw/mwgui/loadingscreen.hpp +++ b/apps/openmw/mwgui/loadingscreen.hpp @@ -3,6 +3,7 @@ #include +#include #include #include @@ -86,6 +87,7 @@ namespace MWGui osg::ref_ptr mTexture; osg::ref_ptr mCopyFramebufferToTextureCallback; + osg::ref_ptr mOldCallback; std::unique_ptr mGuiTexture; void changeWallpaper();