From 2aaf0ed2973960a7a3a86166454f216a9ee73b20 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Nov 2010 17:53:58 +0000 Subject: [PATCH] From Fabien Lavingotte and Robert Osfield, Fixed handling of texture pool size when TextureObject::setAllocate(..) is called. --- include/osg/Texture | 1 + src/osg/Texture.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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; + } } }