]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/ODGauge.cxx
Canvas: clip region rounding and catch negative size.
[simgear.git] / simgear / canvas / ODGauge.cxx
index ce49eb31316370fd68046f33e86f854a07083b9a..3f34f989a8635c27d26fc88e32066e83e2d83cad 100644 (file)
@@ -43,6 +43,7 @@
 #include <osg/ShadeModel>
 #include <osg/StateSet>
 #include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
+#include <osgUtil/RenderBin>
 
 #include <cassert>
 
@@ -51,6 +52,58 @@ namespace simgear
 namespace canvas
 {
 
+  class PreOrderBin:
+    public osgUtil::RenderBin
+  {
+    public:
+
+      PreOrderBin()
+      {}
+      PreOrderBin( const RenderBin& rhs,
+                   const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY ):
+        RenderBin(rhs, copyop)
+      {}
+
+      virtual osg::Object* cloneType() const
+      {
+        return new PreOrderBin();
+      }
+      virtual osg::Object* clone(const osg::CopyOp& copyop) const
+      {
+        return new PreOrderBin(*this,copyop);
+      }
+      virtual bool isSameKindAs(const osg::Object* obj) const
+      {
+        return dynamic_cast<const PreOrderBin*>(obj) != 0L;
+      }
+      virtual const char* className() const
+      {
+        return "PreOrderBin";
+      }
+
+      virtual void sort()
+      {
+        // Do not sort to keep traversal order...
+      }
+  };
+
+#ifndef OSG_INIT_SINGLETON_PROXY
+  /**
+   * http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk/include/osg/Object
+   *
+   * Helper macro that creates a static proxy object to call singleton function
+   * on it's construction, ensuring that the singleton gets initialized at
+   * startup.
+   */
+#  define OSG_INIT_SINGLETON_PROXY(ProxyName, Func)\
+          static struct ProxyName{ ProxyName() { Func; } } s_##ProxyName;
+#endif
+
+  OSG_INIT_SINGLETON_PROXY(
+    PreOrderBinProxy,
+    (osgUtil::RenderBin::addRenderBinPrototype("PreOrderBin", new PreOrderBin))
+  );
+
   //----------------------------------------------------------------------------
   ODGauge::ODGauge():
     _size_x( -1 ),