diff --git a/include/osg/Texture b/include/osg/Texture index 0bc6b8746..9ff0fb291 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -955,6 +955,7 @@ class OSG_EXPORT Texture : public osg::StateAttribute _height = height; _depth = depth; _border = border; + computeSize(); } inline bool match(GLenum target, diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 3b53dced4..9942f5f78 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -91,12 +91,19 @@ void Texture::TextureObject::setAllocated(GLint numMipmapLevels, _allocated=true; if (!match(_profile._target,numMipmapLevels,internalFormat,width,height,depth,border)) { + // keep previous size + unsigned int previousSize = _profile._size; + _profile.set(numMipmapLevels,internalFormat,width,height,depth,border); if (_set) { _set->moveToSet(this, _set->getParent()->getTextureObjectSet(_profile)); - } + + // Update texture pool size + _set->getParent()->getCurrTexturePoolSize() -= previousSize; + _set->getParent()->getCurrTexturePoolSize() += _profile._size; + } } }