From 0aa8008f0a781cca60fbbf8fd4410056f0e4304b Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Sun, 21 Jan 2018 01:23:38 +0100 Subject: [PATCH 1/2] add a virtual getBufferData to Texture --- include/osg/Texture | 3 +++ include/osg/TextureBuffer | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/osg/Texture b/include/osg/Texture index a4f744f68..2376619c9 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -730,6 +730,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; } float getShadowAmbient() const { return _shadow_ambient; } + /** Gets the texture BufferData */ + virtual const BufferData* getBufferData() const { return getImage(0); } /** Sets the texture image for the specified face. */ virtual void setImage(unsigned int face, Image* image) = 0; @@ -739,6 +741,7 @@ class OSG_EXPORT Texture : public osg::StateAttribute /** Gets the texture image for the specified face. */ virtual Image* getImage(unsigned int face) = 0; + /** Gets the const texture image for specified face. */ virtual const Image* getImage(unsigned int face) const = 0; diff --git a/include/osg/TextureBuffer b/include/osg/TextureBuffer index 7a5c603c6..dcdeaf576 100644 --- a/include/osg/TextureBuffer +++ b/include/osg/TextureBuffer @@ -84,11 +84,11 @@ class OSG_EXPORT TextureBuffer : public Texture /** Bind the texture buffer.*/ virtual void apply(State& state) const; - /** Set setBufferData attached */ + /** Set BufferData attached */ void setBufferData(BufferData *bo); - /** Set setBufferData attached */ - const BufferData * getBufferData()const {return _bufferData.get();} + /** Get BufferData attached */ + virtual const BufferData * getBufferData() const { return _bufferData.get(); } protected : virtual ~TextureBuffer(); From 588a9ae10d4ae54d39b4bfa69516ee434a1ad871 Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Sun, 21 Jan 2018 01:24:01 +0100 Subject: [PATCH 2/2] use introduced getBufferData to determine _target->apply requirements. --- src/osg/BindImageTexture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/osg/BindImageTexture.cpp b/src/osg/BindImageTexture.cpp index 592ffa2fb..d5a1361bf 100644 --- a/src/osg/BindImageTexture.cpp +++ b/src/osg/BindImageTexture.cpp @@ -19,8 +19,9 @@ void BindImageTexture::apply(osg::State&state) const { if(_target.valid()) { - osg::Texture::TextureObject *to = _target->getTextureObject( state.getContextID() ); - if( !to ) + Texture::TextureObject *to = _target->getTextureObject( state.getContextID() ); + GLBufferObject *globj = _target->getBufferData()->getBufferObject()->getGLBufferObject( state.getContextID() ); + if( !globj || globj->isDirty() ) { // _target never been applied yet _target->apply(state);