]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/ODGauge.hxx
Canvas::Text: add line-height property.
[simgear.git] / simgear / canvas / ODGauge.hxx
index 64efa84e936ce46335989d2befab1b7047501cb4..825b603bca7e4b959400af9b1a33fa755a6bcbba 100644 (file)
 // Supports now multisampling/mipmapping, usage of the stencil buffer and placing
 // the texture in the scene by certain filter criteria
 //
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
 //
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
+// Library General Public License for more details.
 //
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
 
 #ifndef _SG_OD_GAUGE_HXX
 #define _SG_OD_GAUGE_HXX
 
+#include "canvas_fwd.hxx"
+
 #include <osg/NodeCallback>
 #include <osg/Group>
 
-#include <boost/function.hpp>
-
 namespace osg
 {
   class Camera;
@@ -42,6 +40,9 @@ namespace osg
 
 namespace simgear
 {
+namespace canvas
+{
+
   /**
    * Owner Drawn Gauge (aka render-to-texture) helper class
    */
@@ -49,12 +50,11 @@ namespace simgear
   {
     public:
 
-      typedef boost::function<void(osg::Camera*)> CameraRegistrationCallback;
-
-      ODGauge( const CameraRegistrationCallback& cb_camera_add,
-               const CameraRegistrationCallback& cb_camera_remove );
+      ODGauge();
       virtual ~ODGauge();
 
+      void setSystemAdapter(const SystemAdapterPtr& system_adapter);
+
       /**
        * Set the size of the render target.
        *
@@ -71,6 +71,8 @@ namespace simgear
        */
       void setViewSize(int width, int height = -1);
 
+      osg::Vec2s getViewSize() const;
+
       /**
        * DEPRECATED
        *
@@ -91,6 +93,12 @@ namespace simgear
        */
       void useStencil(bool use = true);
 
+      /**
+       * Enable/Disable additive alpha blending (Can improve results with
+       * transparent background)
+       */
+      void useAdditiveBlend(bool use = true);
+
       /**
        * Set sampling parameters for mipmapping and coverage sampling
        * antialiasing.
@@ -112,7 +120,7 @@ namespace simgear
        * Say if we can render to a texture.
        * @return true if rtt is available
        */
-      bool serviceable(void);
+      bool serviceable() const;
 
       /**
        * Get the OSG camera for drawing this gauge.
@@ -123,34 +131,46 @@ namespace simgear
 
       // Real initialization function. Bad name.
       void allocRT(osg::NodeCallback* camera_cull_callback = 0);
+      void reinit();
+      void clear();
 
-    private:
+    protected:
+
+      SystemAdapterPtr _system_adapter;
 
       int _size_x,
           _size_y,
           _view_width,
           _view_height;
-      bool _use_image_coords,
-           _use_stencil,
-           _use_mipmapping;
+
+      enum Flags
+      {
+        AVAILABLE           = 1,
+        USE_IMAGE_COORDS    = AVAILABLE << 1,
+        USE_STENCIL         = USE_IMAGE_COORDS << 1,
+        USE_MIPMAPPING      = USE_STENCIL << 1,
+        USE_ADDITIVE_BLEND  = USE_MIPMAPPING << 1
+      };
+
+      uint32_t _flags;
 
       // Multisampling parameters
       int  _coverage_samples,
            _color_samples;
 
-      bool rtAvailable;
       osg::ref_ptr<osg::Camera> camera;
       osg::ref_ptr<osg::Texture2D> texture;
 
-      CameraRegistrationCallback _cb_cam_add,
-                                 _cb_cam_remove;
+      bool updateFlag(Flags flag, bool enable);
 
       void updateCoordinateFrame();
       void updateStencil();
       void updateSampling();
+      void updateBlendMode();
 
   };
 
+} // namespace canvas
 } // namespace simgear
 
 #endif // _SG_OD_GAUGE_HXX