From f46b2313052f06f3816db112d4691917e10d3b38 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 19 Nov 2002 12:48:58 +0000 Subject: [PATCH] Added handling of image dirty after a textyre has been bound, the texture is now updated when the image is dirty. --- src/osg/Texture1D.cpp | 4 ++++ src/osg/Texture2D.cpp | 12 +++++++++--- src/osg/Texture3D.cpp | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/osg/Texture1D.cpp b/src/osg/Texture1D.cpp index 32305b693..4ea39d3f0 100644 --- a/src/osg/Texture1D.cpp +++ b/src/osg/Texture1D.cpp @@ -91,6 +91,10 @@ void Texture1D::apply(State& state) const { _subloadCallback->subload(*this,state); } + else if(getModifiedTag(contextID) != _image->getModifiedTag()) + { + applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMimpmapLevels); + } } else if (_subloadCallback.valid()) diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 0e778822e..2809a2259 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -86,14 +86,19 @@ void Texture2D::apply(State& state) const if (handle != 0) { - glBindTexture( GL_TEXTURE_2D, handle ); - if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_2D,state); + if (getTextureParameterDirty(state.getContextID())) + applyTexParameters(GL_TEXTURE_2D,state); if (_subloadCallback.valid()) { _subloadCallback->subload(*this,state); } + else if(getModifiedTag(contextID) != _image->getModifiedTag()) + { + applyTexImage2D(GL_TEXTURE_2D,_image.get(),state, + _textureWidth, _textureHeight, _numMimpmapLevels); + } } else if (_subloadCallback.valid()) @@ -121,7 +126,8 @@ void Texture2D::apply(State& state) const applyTexParameters(GL_TEXTURE_2D,state); - applyTexImage2D(GL_TEXTURE_2D,_image.get(),state, _textureWidth, _textureHeight, _numMimpmapLevels); + applyTexImage2D(GL_TEXTURE_2D,_image.get(),state, + _textureWidth, _textureHeight, _numMimpmapLevels); // in theory the following line is redundent, but in practice // have found that the first frame drawn doesn't apply the textures diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index 4859b70c5..764b0eb48 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -108,6 +108,10 @@ void Texture3D::apply(State& state) const { _subloadCallback->subload(*this,state); } + else if(getModifiedTag(contextID) != _image->getModifiedTag()) + { + applyTexImage3D(GL_TEXTURE_3D,_image.get(),state, _textureWidth, _textureHeight, _textureDepth,_numMimpmapLevels); + } } else if (_subloadCallback.valid())