diff --git a/include/osgUI/Style b/include/osgUI/Style index 0229125b6..714550544 100644 --- a/include/osgUI/Style +++ b/include/osgUI/Style @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include @@ -55,6 +57,9 @@ public: protected: virtual ~Style() {} + osg::ref_ptr _disabledDepthWrite; + osg::ref_ptr _enabledDepthWrite; + osg::ref_ptr _disableColorWriteMask; osg::ref_ptr _clipTexture; osg::Vec4 _backgroundColor; diff --git a/src/osgUI/Style.cpp b/src/osgUI/Style.cpp index aca41863f..8eab21003 100644 --- a/src/osgUI/Style.cpp +++ b/src/osgUI/Style.cpp @@ -45,6 +45,10 @@ Style::Style() //image = osgDB::readImageFile("Images/lz.rgb"); //_clipTexture->setImage(image.get()); + + _disabledDepthWrite = new osg::Depth(osg::Depth::LESS,0.0, 1.0,false); + _enabledDepthWrite = new osg::Depth(osg::Depth::LESS,0.0, 1.0,true); + _disableColorWriteMask = new osg::ColorMask(false, false, false, false); } Style::Style(const Style& style, const osg::CopyOp& copyop): @@ -91,8 +95,8 @@ osg::Node* Style::createDepthSetPanel(const osg::BoundingBox& extents) geometry->addPrimitiveSet( new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4) ); osg::ref_ptr stateset = geometry->getOrCreateStateSet(); - stateset->setAttributeAndModes( new osg::Depth(osg::Depth::LESS,0.0, 1.0,true), osg::StateAttribute::ON); - stateset->setAttributeAndModes( new osg::ColorMask(false, false, false, false)); + stateset->setAttributeAndModes( _enabledDepthWrite.get(), osg::StateAttribute::ON); + stateset->setAttributeAndModes( _disableColorWriteMask.get() ); return geometry.release(); } @@ -136,7 +140,7 @@ void Style::setupDialogStateSet(osg::StateSet* stateset) { stateset->setRenderBinDetails(5, "TraversalOrderBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); - stateset->setAttributeAndModes( new osg::Depth(osg::Depth::LESS,0.0, 1.0,false), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE ); + stateset->setAttributeAndModes( _disabledDepthWrite.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE ); } void Style::setupClipStateSet(const osg::BoundingBox& extents, osg::StateSet* stateset)