]> git.mxchange.org Git - simgear.git/commitdiff
Canvas: set blend function for elements and prevent autoresize
authorThomas Geymayer <tomgey@gmail.com>
Sun, 2 Jun 2013 21:32:53 +0000 (23:32 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Sun, 2 Jun 2013 21:32:53 +0000 (23:32 +0200)
simgear/canvas/Canvas.cxx
simgear/canvas/ODGauge.cxx
simgear/canvas/elements/CanvasElement.cxx
simgear/canvas/elements/CanvasElement.hxx
simgear/canvas/elements/CanvasImage.cxx
simgear/canvas/elements/CanvasPath.cxx

index 585281007df98d1ed3201dd453ecb01d1cb9d050..4e4255575f68c0e32f7db6a3ea50278770002512 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/foreach.hpp>
-#include <iostream>
 
 namespace simgear
 {
index a95581a1daaaea833b12e053c4d2e7c6384c127c..ce49eb31316370fd68046f33e86f854a07083b9a 100644 (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);
     }
index cb18634228193a2b30232ceac81d6594f7a42acd..e581e5143e8d636b27b8826588ddcf0c5480ecd2 100644 (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 )
index 65e84dbf339be344ba8dc215a69ec527e25d12c5..146cd0d4a9887875d26be9446547cf5171511670 100644 (file)
@@ -133,7 +133,8 @@ namespace canvas
 
       enum Attributes
       {
-        LAST_ATTRIBUTE  = 0x0001
+        BLEND_FUNC = 0x0001,
+        LAST_ATTRIBUTE  = BLEND_FUNC << 1
       };
 
       enum TransformType
index d472a6aef4cf828d9afa62e20404e9c710fb185d..5cd5ddc368e958319503509aa192b8088ceaf3c8 100644 (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);
index 5e9efa083b9e820655c8586764ead75caa5ef2a5..e2281905c5f07d72ca0c971b2c4f82ae562f74f9 100644 (file)
@@ -20,7 +20,6 @@
 #include <simgear/scene/util/parse_color.hxx>
 
 #include <osg/Drawable>
-#include <osg/BlendFunc>
 
 #include <vg/openvg.h>
 #include <cassert>