From: Thomas Geymayer Date: Fri, 31 May 2013 17:17:30 +0000 (+0200) Subject: Canvas Image: fix updating while showing nested canvas. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=83da4e92486f3ab496eb43a90e46dc45b293e925;p=simgear.git Canvas Image: fix updating while showing nested canvas. --- diff --git a/simgear/canvas/elements/CanvasImage.cxx b/simgear/canvas/elements/CanvasImage.cxx index bc6ff091..d472a6ae 100644 --- a/simgear/canvas/elements/CanvasImage.cxx +++ b/simgear/canvas/elements/CanvasImage.cxx @@ -149,6 +149,24 @@ namespace canvas { Element::update(dt); + osg::Texture2D* texture = dynamic_cast + ( + _geom->getOrCreateStateSet() + ->getTextureAttribute(0, osg::StateAttribute::TEXTURE) + ); + simgear::canvas::CanvasPtr canvas = _src_canvas.lock(); + + if( (_attributes_dirty & SRC_CANVAS) + // check if texture has changed (eg. due to resizing) + || (canvas && texture != canvas->getTexture()) ) + { + _geom->getOrCreateStateSet() + ->setTextureAttribute(0, canvas ? canvas->getTexture() : 0); + + if( !canvas || canvas->isInit() ) + _attributes_dirty &= ~SRC_CANVAS; + } + if( !_attributes_dirty ) return; @@ -335,8 +353,7 @@ namespace canvas _canvas.lock()->removeChildCanvas(_src_canvas); _src_canvas = canvas; - _geom->getOrCreateStateSet() - ->setTextureAttribute(0, canvas ? canvas->getTexture() : 0); + _attributes_dirty |= SRC_CANVAS; _geom->setCullCallback(canvas ? new CullCallback(canvas) : 0); if( !_src_canvas.expired() ) diff --git a/simgear/canvas/elements/CanvasImage.hxx b/simgear/canvas/elements/CanvasImage.hxx index 105c628f..3b8dca78 100644 --- a/simgear/canvas/elements/CanvasImage.hxx +++ b/simgear/canvas/elements/CanvasImage.hxx @@ -88,7 +88,8 @@ namespace canvas enum ImageAttributes { SRC_RECT = LAST_ATTRIBUTE << 1, // Source image rectangle - DEST_SIZE = SRC_RECT << 1 // Element size + DEST_SIZE = SRC_RECT << 1, // Element size + SRC_CANVAS = DEST_SIZE << 1 }; virtual void childChanged(SGPropertyNode * child);