{
Element::update(dt);
+ osg::Texture2D* texture = dynamic_cast<osg::Texture2D*>
+ (
+ _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;
_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() )
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);