mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-06 19:01:21 +03:00
Reduce texture memory usage in OpenMW
This commit is contained in:
parent
d772da3720
commit
1a5407af98
3 changed files with 14 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue