Fix render order of canvas elements

This commit is contained in:
Thomas Geymayer 2013-07-12 16:13:06 +02:00
parent 757ba03918
commit 5320d0ecaa
4 changed files with 51 additions and 4 deletions

View File

@ -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);

View 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,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<const PreOrderBin*>(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 ),

View File

@ -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
);
}
//----------------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ namespace canvas
Text::TextOSG::TextOSG(canvas::Text* text):
_text_element(text)
{
setBackdropImplementation(NO_DEPTH_BUFFER);
}
//----------------------------------------------------------------------------