]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/ODGauge.cxx
Fix VS2010 lack of fminf
[simgear.git] / simgear / canvas / ODGauge.cxx
index ebc92fe582d309eb07ee815be77f38f1a80ca585..4a2b7facf54b83644e633430cf4abfd4c9001ce2 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include "ODGauge.hxx"
+#include "Canvas.hxx"
 #include "CanvasSystemAdapter.hxx"
 
 #include <simgear/debug/logstream.hxx>
@@ -43,6 +44,7 @@
 #include <osg/ShadeModel>
 #include <osg/StateSet>
 #include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
+#include <osg/Version>
 #include <osgUtil/RenderBin>
 
 #include <cassert>
@@ -87,6 +89,18 @@ namespace canvas
       }
   };
 
+#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))
@@ -111,12 +125,6 @@ namespace canvas
     clear();
   }
 
-  //----------------------------------------------------------------------------
-  void ODGauge::setSystemAdapter(const SystemAdapterPtr& system_adapter)
-  {
-    _system_adapter = system_adapter;
-  }
-
   //----------------------------------------------------------------------------
   void ODGauge::setSize(int size_x, int size_y)
   {
@@ -250,8 +258,8 @@ namespace canvas
     updateSampling();
     updateBlendMode();
 
-    if( _system_adapter )
-      _system_adapter->addCamera(camera.get());
+    if( Canvas::getSystemAdapter() )
+      Canvas::getSystemAdapter()->addCamera(camera.get());
 
     _flags |= AVAILABLE;
   }
@@ -259,7 +267,15 @@ namespace canvas
   //----------------------------------------------------------------------------
   void ODGauge::reinit()
   {
-    osg::NodeCallback* cull_callback = camera ? camera->getCullCallback() : 0;
+    osg::NodeCallback* cull_callback =
+      camera
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      ? camera->getCullCallback()
+#else
+      ? dynamic_cast<osg::NodeCallback*>(camera->getCullCallback())
+#endif
+      : 0;
+
     clear();
     allocRT(cull_callback);
   }
@@ -267,8 +283,8 @@ namespace canvas
   //----------------------------------------------------------------------------
   void ODGauge::clear()
   {
-    if( camera.valid() && _system_adapter )
-      _system_adapter->removeCamera(camera.get());
+    if( camera.valid() && Canvas::getSystemAdapter() )
+      Canvas::getSystemAdapter()->removeCamera(camera.get());
     camera.release();
     texture.release();