From 654764a0e9a3648d988c5091e7cc4f63ffab0783 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 27 Jul 2004 13:24:35 +0000 Subject: [PATCH] Fixed unref image so it only unref's when images are STATIC --- src/osg/Texture1D.cpp | 2 +- src/osg/Texture2D.cpp | 2 +- src/osg/Texture3D.cpp | 2 +- src/osg/TextureCubeMap.cpp | 9 ++++++--- src/osg/TextureRectangle.cpp | 11 ++++++++++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/osg/Texture1D.cpp b/src/osg/Texture1D.cpp index 675761476..22cc94116 100644 --- a/src/osg/Texture1D.cpp +++ b/src/osg/Texture1D.cpp @@ -152,7 +152,7 @@ void Texture1D::apply(State& state) const // update the modified tag to show that it is upto date. getModifiedTag(contextID) = _image->getModifiedTag(); - if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC) + if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC) { Texture1D* non_const_this = const_cast(this); non_const_this->_image = 0; diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 303cbb69d..e6918af88 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -188,7 +188,7 @@ void Texture2D::apply(State& state) const getModifiedTag(contextID) = _image->getModifiedTag(); - if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC) + if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC) { Texture2D* non_const_this = const_cast(this); non_const_this->_image = 0; diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index 3752bc591..d12e23416 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -168,7 +168,7 @@ void Texture3D::apply(State& state) const // update the modified tag to show that it is upto date. getModifiedTag(contextID) = _image->getModifiedTag(); - if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC) + if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC) { Texture3D* non_const_this = const_cast(this); non_const_this->_image = 0; diff --git a/src/osg/TextureCubeMap.cpp b/src/osg/TextureCubeMap.cpp index 75c5b2f34..738cbec8c 100644 --- a/src/osg/TextureCubeMap.cpp +++ b/src/osg/TextureCubeMap.cpp @@ -284,12 +284,15 @@ void TextureCubeMap::apply(State& state) const } - if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC) + if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded()) { TextureCubeMap* non_const_this = const_cast(this); for (int n=0; n<6; n++) - { - non_const_this->_images[n] = 0; + { + if (_images[n].valid() && _images[n]->getDataVariance()==STATIC) + { + non_const_this->_images[n] = 0; + } } } diff --git a/src/osg/TextureRectangle.cpp b/src/osg/TextureRectangle.cpp index ca352ff30..f1f1a2441 100644 --- a/src/osg/TextureRectangle.cpp +++ b/src/osg/TextureRectangle.cpp @@ -36,6 +36,8 @@ TextureRectangle::TextureRectangle(): _textureWidth(0), _textureHeight(0) { + osg::notify(osg::NOTICE)<<"TextureRectangle::TextureRectangle() "<bind(); if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_RECTANGLE, state); @@ -182,7 +187,7 @@ void TextureRectangle::apply(State& state) const textureObject->setAllocated(1,_internalFormat,_textureWidth,_textureHeight,1,0); - if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC) + if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC) { TextureRectangle* non_const_this = const_cast(this); non_const_this->_image = 0; @@ -212,6 +217,8 @@ void TextureRectangle::applyTexParameters(GLenum target, State& state) const void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const { // if we don't have a valid image we can't create a texture! + osg::notify(osg::NOTICE)<<"TextureRectangle::applyTexImage_load "<data()) return; @@ -257,6 +264,8 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight, GLint& inInternalFormat) const { + osg::notify(osg::NOTICE)<<"TextureRectangle::applyTexImage_subload "<data()) return;