1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-12 04:14:05 +00:00

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
This commit is contained in:
psi29a 2020-12-17 22:51:04 +00:00 committed by AnyOldName3
parent 8db2ba2b38
commit 96a87b582c
2 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include <osgViewer/Viewer>
#include <osg/Texture2D>
#include <osg/Version>
#include <MyGUI_RenderManager.h>
#include <MyGUI_ScrollBar.h>
@ -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;
}

View File

@ -3,6 +3,7 @@
#include <memory>
#include <osg/Camera>
#include <osg/Timer>
#include <osg/ref_ptr>
@ -86,6 +87,7 @@ namespace MWGui
osg::ref_ptr<osg::Texture2D> mTexture;
osg::ref_ptr<CopyFramebufferToTextureCallback> mCopyFramebufferToTextureCallback;
osg::ref_ptr<osg::Camera::DrawCallback> mOldCallback;
std::unique_ptr<MyGUI::ITexture> mGuiTexture;
void changeWallpaper();