mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 01:10:10 +00:00
Improve MyGUI texture updates
This commit is contained in:
parent
fd3d49c171
commit
a18663c8b3
@ -1098,11 +1098,7 @@ namespace MWGui
|
|||||||
else if (it->first == "GUI" && it->second == "subtitles")
|
else if (it->first == "GUI" && it->second == "subtitles")
|
||||||
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
||||||
else if (it->first == "GUI" && it->second == "menu transparency")
|
else if (it->first == "GUI" && it->second == "menu transparency")
|
||||||
{
|
|
||||||
mViewer->stopThreading();
|
|
||||||
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
||||||
mViewer->startThreading();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +141,21 @@ namespace osgMyGUI
|
|||||||
if (!mLockedImage.valid())
|
if (!mLockedImage.valid())
|
||||||
throw std::runtime_error("Texture not locked");
|
throw std::runtime_error("Texture not locked");
|
||||||
|
|
||||||
|
// mTexture might be in use by the draw thread, so create a new texture instead and use that.
|
||||||
|
osg::ref_ptr<osg::Texture2D> newTexture = new osg::Texture2D;
|
||||||
|
newTexture->setTextureSize(getWidth(), getHeight());
|
||||||
|
newTexture->setSourceFormat(mTexture->getSourceFormat());
|
||||||
|
newTexture->setSourceType(mTexture->getSourceType());
|
||||||
|
newTexture->setFilter(osg::Texture::MIN_FILTER, mTexture->getFilter(osg::Texture::MIN_FILTER));
|
||||||
|
newTexture->setFilter(osg::Texture::MAG_FILTER, mTexture->getFilter(osg::Texture::MAG_FILTER));
|
||||||
|
newTexture->setWrap(osg::Texture::WRAP_S, mTexture->getWrap(osg::Texture::WRAP_S));
|
||||||
|
newTexture->setWrap(osg::Texture::WRAP_T, mTexture->getWrap(osg::Texture::WRAP_T));
|
||||||
|
newTexture->setImage(mLockedImage.get());
|
||||||
// Tell the texture it can get rid of the image for static textures (since
|
// Tell the texture it can get rid of the image for static textures (since
|
||||||
// they aren't expected to update much at all).
|
// they aren't expected to update much at all).
|
||||||
mTexture->setImage(mLockedImage.get());
|
newTexture->setUnRefImageDataAfterApply(mUsage.isValue(MyGUI::TextureUsage::Static) ? true : false);
|
||||||
mTexture->setUnRefImageDataAfterApply(mUsage.isValue(MyGUI::TextureUsage::Static) ? true : false);
|
|
||||||
mTexture->dirtyTextureObject();
|
mTexture = newTexture;
|
||||||
|
|
||||||
mLockedImage = nullptr;
|
mLockedImage = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,6 @@ namespace osgMyGUI
|
|||||||
|
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
|
|
||||||
/// @warning If you intend to change a texture during the frame update, you must either declare the texture with DataVariance::DYNAMIC
|
|
||||||
/// or temporarily stop the viewer threading, to prevent race conditions with the draw thread.
|
|
||||||
virtual void* lock(MyGUI::TextureUsage access);
|
virtual void* lock(MyGUI::TextureUsage access);
|
||||||
virtual void unlock();
|
virtual void unlock();
|
||||||
virtual bool isLocked();
|
virtual bool isLocked();
|
||||||
|
Loading…
Reference in New Issue
Block a user