|
|
|
@ -45,8 +45,6 @@ namespace MWGui
|
|
|
|
|
, mNestedLoadingCount(0)
|
|
|
|
|
, mProgress(0)
|
|
|
|
|
, mShowWallpaper(true)
|
|
|
|
|
, mOldCallback(nullptr)
|
|
|
|
|
, mHasCallback(false)
|
|
|
|
|
{
|
|
|
|
|
mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize());
|
|
|
|
|
|
|
|
|
@ -147,35 +145,11 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void operator () (osg::RenderInfo& renderInfo) const override
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mMutex);
|
|
|
|
|
mOneshot = false;
|
|
|
|
|
}
|
|
|
|
|
mSignal.notify_all();
|
|
|
|
|
|
|
|
|
|
int w = renderInfo.getCurrentCamera()->getViewport()->width();
|
|
|
|
|
int h = renderInfo.getCurrentCamera()->getViewport()->height();
|
|
|
|
|
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mMutex);
|
|
|
|
|
mOneshot = false;
|
|
|
|
|
}
|
|
|
|
|
mSignal.notify_all();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wait()
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mMutex);
|
|
|
|
|
while (mOneshot)
|
|
|
|
|
mSignal.wait(lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void waitUntilInvoked()
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mMutex);
|
|
|
|
|
while (mOneshot)
|
|
|
|
|
mSignal.wait(lock);
|
|
|
|
|
mOneshot = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void reset()
|
|
|
|
@ -185,8 +159,6 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
mutable bool mOneshot;
|
|
|
|
|
mutable std::mutex mMutex;
|
|
|
|
|
mutable std::condition_variable mSignal;
|
|
|
|
|
osg::ref_ptr<osg::Texture2D> mTexture;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -362,14 +334,12 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 10)
|
|
|
|
|
mViewer->getCamera()->removeInitialDrawCallback(mCopyFramebufferToTextureCallback);
|
|
|
|
|
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
|
|
|
|
|
mCopyFramebufferToTextureCallback->reset();
|
|
|
|
|
mHasCallback = true;
|
|
|
|
|
|
|
|
|
|
mBackgroundImage->setBackgroundImage("");
|
|
|
|
|
mBackgroundImage->setVisible(false);
|
|
|
|
@ -412,21 +382,6 @@ namespace MWGui
|
|
|
|
|
mViewer->renderingTraversals();
|
|
|
|
|
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
|
|
|
|
|
|
|
|
|
if (mHasCallback)
|
|
|
|
|
{
|
|
|
|
|
mCopyFramebufferToTextureCallback->waitUntilInvoked();
|
|
|
|
|
|
|
|
|
|
// Note that we are removing the callback before the draw thread has returned from it.
|
|
|
|
|
// This is OK as we are retaining the ref_ptr.
|
|
|
|
|
#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
|
|
|
|
|
mHasCallback = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mLastRenderTime = mTimer.time_m();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|