#endif
#include "ODGauge.hxx"
+#include "Canvas.hxx"
#include "CanvasSystemAdapter.hxx"
#include <simgear/debug/logstream.hxx>
#include <osg/ShadeModel>
#include <osg/StateSet>
#include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
+#include <osg/Version>
+#include <osgUtil/RenderBin>
#include <cassert>
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 ),
clear();
}
- //----------------------------------------------------------------------------
- void ODGauge::setSystemAdapter(const SystemAdapterPtr& system_adapter)
- {
- _system_adapter = system_adapter;
- }
-
//----------------------------------------------------------------------------
void ODGauge::setSize(int size_x, int size_y)
{
}
//----------------------------------------------------------------------------
- bool ODGauge::serviceable(void)
+ bool ODGauge::serviceable() const
{
return _flags & AVAILABLE;
}
if( !texture )
{
texture = new osg::Texture2D;
+ texture->setResizeNonPowerOfTwoHint(false);
texture->setTextureSize(_size_x, _size_y);
texture->setInternalFormat(GL_RGBA);
}
updateSampling();
updateBlendMode();
- if( _system_adapter )
- _system_adapter->addCamera(camera.get());
+ if( Canvas::getSystemAdapter() )
+ Canvas::getSystemAdapter()->addCamera(camera.get());
_flags |= AVAILABLE;
}
//----------------------------------------------------------------------------
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);
}
//----------------------------------------------------------------------------
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();