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.
This commit is contained in:
parent
8e2f1bdb72
commit
777e4ab9f1
@ -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
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <osg/FrontFace>
|
||||
#include <osg/PolygonMode>
|
||||
#include <osg/Transparency>
|
||||
#include <osg/Depth>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user