Canvas Image: fix updating while showing nested canvas.

This commit is contained in:
Thomas Geymayer 2013-05-31 19:17:30 +02:00
parent 2c879095d9
commit 83da4e9248
2 changed files with 21 additions and 3 deletions

View File

@ -149,6 +149,24 @@ namespace canvas
{
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;
@ -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() )

View File

@ -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);