From 777e4ab9f1a589d737f94e750218818c1602a110 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 29 Sep 2001 18:34:26 +0000 Subject: [PATCH] Added setAttributeAndModes(new Depth,StateAttribute::ON); to the StateSet::setGlobalDefault() so that the correct default for the glDepthFunc etc are set up for scene graphs, and allows override of these value which risk of inheriting state on to the rest of the scene graph. This has allowed the hangglide demo to be simplified since it now doesn't need to set the global Depth instance itself. --- src/Demos/hangglide/hangglide.cpp | 16 ---------------- src/osg/StateSet.cpp | 3 +++ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Demos/hangglide/hangglide.cpp b/src/Demos/hangglide/hangglide.cpp index 7d95c4377..8bd0d5cb1 100644 --- a/src/Demos/hangglide/hangglide.cpp +++ b/src/Demos/hangglide/hangglide.cpp @@ -149,22 +149,6 @@ int main( int argc, char **argv ) osgGLUT::Viewer viewer; viewer.addViewport( rootnode ); - - osg::StateSet* stateset = rootnode->getStateSet(); - if (stateset==NULL) - { - stateset = new osg::StateSet; - rootnode->setStateSet(stateset); - } - - // set up depth to be inherited by the rest of the scene unless - // overrideen. - osg::Depth* rootDepth = new osg::Depth; - rootDepth->setFunction(osg::Depth::LESS); - rootDepth->setRange(0.0,1.0); - - stateset->setAttributeAndModes(rootDepth, osg::StateAttribute::ON ); - unsigned int pos = viewer.registerCameraManipulator(new GliderManipulator()); // Open window so camera manipulator's warp pointer request will succeed diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index 14fa1c070..4531cf998 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace osg; @@ -56,6 +57,8 @@ void StateSet::setGlobalDefaults() setAttributeAndModes(new PolygonMode,StateAttribute::OFF); setAttributeAndModes(new Transparency,StateAttribute::OFF); + + setAttributeAndModes(new Depth,StateAttribute::ON); }