Canvas: set blend function for elements and prevent autoresize

This commit is contained in:
Thomas Geymayer
2013-06-02 23:32:53 +02:00
parent 5c8f0cc966
commit c3af88dfc1
6 changed files with 24 additions and 5 deletions

View File

@@ -31,7 +31,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/foreach.hpp>
#include <iostream>
namespace simgear
{

View File

@@ -201,6 +201,7 @@ namespace canvas
if( !texture )
{
texture = new osg::Texture2D;
texture->setResizeNonPowerOfTwoHint(false);
texture->setTextureSize(_size_x, _size_y);
texture->setInternalFormat(GL_RGBA);
}

View File

@@ -21,6 +21,7 @@
#include <simgear/canvas/CanvasEventListener.hxx>
#include <simgear/canvas/CanvasEventVisitor.hxx>
#include <simgear/canvas/MouseEvent.hxx>
#include <simgear/scene/material/parseBlendFunc.hxx>
#include <osg/Drawable>
#include <osg/Geode>
@@ -134,6 +135,20 @@ namespace canvas
// Update bounding box on manual update (manual updates pass zero dt)
if( dt == 0 && _drawable )
_drawable->getBound();
if( _attributes_dirty & BLEND_FUNC )
{
parseBlendFunc(
_transform->getOrCreateStateSet(),
_node->getChild("blend-source"),
_node->getChild("blend-destination"),
_node->getChild("blend-source-rgb"),
_node->getChild("blend-destination-rgb"),
_node->getChild("blend-source-alpha"),
_node->getChild("blend-destination-alpha")
);
_attributes_dirty &= ~BLEND_FUNC;
}
}
//----------------------------------------------------------------------------
@@ -300,13 +315,16 @@ namespace canvas
SGPropertyNode *parent = child->getParent();
if( parent == _node )
{
const std::string& name = child->getNameString();
if( setStyle(child) )
return;
else if( child->getNameString() == "update" )
else if( name == "update" )
return update(0);
else if( child->getNameString() == "visible" )
else if( name == "visible" )
// TODO check if we need another nodemask
return _transform->setNodeMask( child->getBoolValue() ? 0xffffffff : 0 );
else if( boost::starts_with(name, "blend-") )
return (void)(_attributes_dirty |= BLEND_FUNC);
}
else if( parent->getParent() == _node
&& parent->getNameString() == NAME_TRANSFORM )

View File

@@ -133,7 +133,8 @@ namespace canvas
enum Attributes
{
LAST_ATTRIBUTE = 0x0001
BLEND_FUNC = 0x0001,
LAST_ATTRIBUTE = BLEND_FUNC << 1
};
enum TransformType

View File

@@ -378,6 +378,7 @@ namespace canvas
// remove canvas...
setSrcCanvas( CanvasPtr() );
_texture->setResizeNonPowerOfTwoHint(false);
_texture->setImage(img);
_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);

View File

@@ -20,7 +20,6 @@
#include <simgear/scene/util/parse_color.hxx>
#include <osg/Drawable>
#include <osg/BlendFunc>
#include <vg/openvg.h>
#include <cassert>