From: Thomas Geymayer Date: Fri, 12 Jul 2013 14:13:06 +0000 (+0200) Subject: Fix render order of canvas elements X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5320d0ecaa696eb2712598879a15ae505bb65e4f;p=simgear.git Fix render order of canvas elements --- diff --git a/simgear/canvas/Canvas.cxx b/simgear/canvas/Canvas.cxx index d2f97ed1..fa671238 100644 --- a/simgear/canvas/Canvas.cxx +++ b/simgear/canvas/Canvas.cxx @@ -227,9 +227,6 @@ namespace canvas camera->addChild(_root_group->getMatrixTransform()); - // Ensure objects are drawn in order of traversal - camera->getOrCreateStateSet()->setBinName("TraversalOrderBin"); - if( _texture.serviceable() ) { setStatusFlags(STATUS_OK); diff --git a/simgear/canvas/ODGauge.cxx b/simgear/canvas/ODGauge.cxx index ce49eb31..ebc92fe5 100644 --- a/simgear/canvas/ODGauge.cxx +++ b/simgear/canvas/ODGauge.cxx @@ -43,6 +43,7 @@ #include #include #include // for GL_DEPTH_STENCIL_EXT on Windows +#include #include @@ -51,6 +52,46 @@ 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(obj) != 0L; + } + virtual const char* className() const + { + return "PreOrderBin"; + } + + virtual void sort() + { + // Do not sort to keep traversal order... + } + }; + + OSG_INIT_SINGLETON_PROXY( + PreOrderBinProxy, + (osgUtil::RenderBin::addRenderBinPrototype("PreOrderBin", new PreOrderBin)) + ); + //---------------------------------------------------------------------------- ODGauge::ODGauge(): _size_x( -1 ), diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index 8d33eff2..a1271169 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -521,6 +521,15 @@ namespace canvas { addStyle("clip", "", &Element::setClip, false); } + + // Ensure elements are drawn in order they appear in the element tree + _transform->getOrCreateStateSet() + ->setRenderBinDetails + ( + 0, + "PreOrderBin", + osg::StateSet::OVERRIDE_RENDERBIN_DETAILS + ); } //---------------------------------------------------------------------------- diff --git a/simgear/canvas/elements/CanvasText.cxx b/simgear/canvas/elements/CanvasText.cxx index 1aca55db..e04ff79e 100644 --- a/simgear/canvas/elements/CanvasText.cxx +++ b/simgear/canvas/elements/CanvasText.cxx @@ -54,7 +54,7 @@ namespace canvas Text::TextOSG::TextOSG(canvas::Text* text): _text_element(text) { - + setBackdropImplementation(NO_DEPTH_BUFFER); } //----------------------------------------------------------------------------