Reduce texture memory usage in OpenMW

This commit is contained in:
scrawl 2015-05-02 19:36:36 +02:00
parent d772da3720
commit 1a5407af98
3 changed files with 14 additions and 2 deletions

View file

@ -37,10 +37,16 @@ namespace Resource
TextureManager::TextureManager(const VFS::Manager *vfs)
: mVFS(vfs)
, mWarningTexture(createWarningTexture())
, mUnRefImageDataAfterApply(false)
{
}
void TextureManager::setUnRefImageDataAfterApply(bool unref)
{
mUnRefImageDataAfterApply = unref;
}
/*
osg::ref_ptr<osg::Image> TextureManager::getImage(const std::string &filename)
{
@ -91,8 +97,7 @@ namespace Resource
texture->setWrap(osg::Texture::WRAP_S, wrapS);
texture->setWrap(osg::Texture::WRAP_T, wrapT);
// Can be enabled for single-context, i.e. in openmw
//texture->setUnRefImageDataAfterApply(true);
texture->setUnRefImageDataAfterApply(mUnRefImageDataAfterApply);
mTextures.insert(std::make_pair(key, texture));
return texture;

View file

@ -24,6 +24,10 @@ namespace Resource
// TODO: texture filtering settings
/// Keep a copy of the texture data around in system memory? This is needed when using multiple graphics contexts,
/// otherwise should be disabled to reduce memory usage.
void setUnRefImageDataAfterApply(bool unref);
/// Create or retrieve a Texture2D using the specified image filename, and wrap parameters.
osg::ref_ptr<osg::Texture2D> getTexture2D(const std::string& filename, osg::Texture::WrapMode wrapS, osg::Texture::WrapMode wrapT);
@ -43,6 +47,7 @@ namespace Resource
osg::ref_ptr<osg::Texture2D> mWarningTexture;
bool mUnRefImageDataAfterApply;
};
}