forked from mirror/openmw-tes3mp
Improve MyGUI texture updates
This commit is contained in:
parent
fd3d49c171
commit
a18663c8b3
3 changed files with 13 additions and 9 deletions
|
@ -1098,11 +1098,7 @@ namespace MWGui
|
|||
else if (it->first == "GUI" && it->second == "subtitles")
|
||||
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
||||
else if (it->first == "GUI" && it->second == "menu transparency")
|
||||
{
|
||||
mViewer->stopThreading();
|
||||
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
||||
mViewer->startThreading();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,11 +141,21 @@ namespace osgMyGUI
|
|||
if (!mLockedImage.valid())
|
||||
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
|
||||
// they aren't expected to update much at all).
|
||||
mTexture->setImage(mLockedImage.get());
|
||||
mTexture->setUnRefImageDataAfterApply(mUsage.isValue(MyGUI::TextureUsage::Static) ? true : false);
|
||||
mTexture->dirtyTextureObject();
|
||||
newTexture->setUnRefImageDataAfterApply(mUsage.isValue(MyGUI::TextureUsage::Static) ? true : false);
|
||||
|
||||
mTexture = newTexture;
|
||||
|
||||
mLockedImage = nullptr;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace osgMyGUI
|
|||
|
||||
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 unlock();
|
||||
virtual bool isLocked();
|
||||
|
|
Loading…
Reference in a new issue