diff --git a/examples/osgprerender/osgprerender.cpp b/examples/osgprerender/osgprerender.cpp index 662767a28..1183000c1 100644 --- a/examples/osgprerender/osgprerender.cpp +++ b/examples/osgprerender/osgprerender.cpp @@ -103,7 +103,7 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv) osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; // set up the background color and clear mask. - rtts->setClearColor(osg::Vec4(0.1f,0.1f,0.3f,0.0f)); + rtts->setClearColor(osg::Vec4(0.1f,0.1f,0.3f,1.0f)); rtts->setClearMask(previous_stage->getClearMask()); // set up to charge the same RenderStageLighting is the parent previous stage. diff --git a/examples/osgshadowtexture/CreateShadowedScene.cpp b/examples/osgshadowtexture/CreateShadowedScene.cpp index 3546fa174..21d448a79 100644 --- a/examples/osgshadowtexture/CreateShadowedScene.cpp +++ b/examples/osgshadowtexture/CreateShadowedScene.cpp @@ -102,7 +102,7 @@ void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::Cull osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; // set up the background color and clear mask. - rtts->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,0.0f)); + rtts->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); rtts->setClearMask(previous_stage->getClearMask()); // set up to charge the same RenderStageLighting is the parent previous stage. diff --git a/src/osg/DisplaySettings.cpp b/src/osg/DisplaySettings.cpp index 11461b759..edcde4616 100644 --- a/src/osg/DisplaySettings.cpp +++ b/src/osg/DisplaySettings.cpp @@ -99,11 +99,7 @@ void DisplaySettings::setDefaults() _minimumNumberAlphaBits = 0; _minimumNumberStencilBits = 0; - #ifdef __sgi - _maxNumOfGraphicsContexts = 4; - #else _maxNumOfGraphicsContexts = 1; - #endif } ApplicationUsageProxy e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_STEREO_MODE ","QUAD_BUFFER | ANAGLYPHIC | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE"); diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 069dc6537..6a96ba0c4 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -95,10 +95,12 @@ int Image::compare(const Image& rhs) const COMPARE_StateAttribute_Parameter(_packing) COMPARE_StateAttribute_Parameter(_modifiedTag) - // still need implement checks for - // _data - // _mipmapData - + if (_datarhs._data) return 1; + + if (_mipmapDatarhs._mipmapData) return 1; + return 0; } diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index b3bf2a3ef..22374ec69 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -12,6 +12,7 @@ */ #include +#include #include #include @@ -224,16 +225,71 @@ void OsgCameraGroup::realize( ThreadingModel thread_model) _ds->setMaxNumberOfGraphicsContexts( _cfg->getNumberOfCameras() ); _shvec.clear(); + + osg::Node* node = getTopMostSceneData(); + if (node) + { + // traverse the scene graphs gathering the requirements of the OpenGL buffers. + osgUtil::DisplayRequirementsVisitor drv; + drv.setDisplaySettings(_ds.get()); + node->accept(drv); + } + + unsigned int numMultiSamples = 0; + + #ifdef __sgi + // switch on anti-aliasing by default, just in case we have an Onyx :-) + numMultiSamples = 4; + #endif + + // set up each render stage to clear the appropriate buffers. + GLbitfield clear_mask=0; + if (_ds->getRGB()) clear_mask |= GL_COLOR_BUFFER_BIT; + if (_ds->getDepthBuffer()) clear_mask |= GL_DEPTH_BUFFER_BIT; + if (_ds->getStencilBuffer()) clear_mask |= GL_STENCIL_BUFFER_BIT; for( unsigned int i = 0; i < _cfg->getNumberOfCameras(); i++ ) { Producer::Camera *cam = _cfg->getCamera(i); + + // create the scene handler. osgProducer::OsgSceneHandler *sh = new osgProducer::OsgSceneHandler(_ds.get()); sh->setDefaults(); _shvec.push_back( sh ); cam->setSceneHandler( sh ); + + // set up the clear mask. + osgUtil::RenderStage *stage = sh->getRenderStage(); + if (stage) stage->setClearMask(clear_mask); + + // set the realize callback. Producer::RenderSurface* rs = cam->getRenderSurface(); rs->setRealizeCallback( new RenderSurfaceRealizeCallback(this, sh)); + + // set up the visual chooser. + if (_ds.valid() || numMultiSamples!=0) + { + Producer::VisualChooser* rs_vc = rs->getVisualChooser(); + if (!rs_vc) + { + rs_vc = new Producer::VisualChooser; + rs_vc->setSimpleConfiguration(); + rs->setVisualChooser(rs_vc); + } + if (_ds->getStereo() && _ds->getStereoMode()==osg::DisplaySettings::QUAD_BUFFER) rs_vc->useStereo(); + if (_ds->getStencilBuffer()) rs_vc->setStencilSize(_ds->getMinimumNumStencilBits()); + if (_ds->getAlphaBuffer()) rs_vc->setAlphaSize(_ds->getMinimumNumAlphaBits()); + + if (numMultiSamples) + { + #if defined( GLX_SAMPLES_SGIS ) + rs_vc->addExtendedAttribute( GLX_SAMPLES_SGIS, numMultiSamples); + #endif + #if defined( GLX_SAMPLES_BUFFER_SGIS ) + rs_vc->addExtendedAttribute( GLX_SAMPLES_BUFFER_SGIS, 1); + #endif + } + } } if( _global_stateset == NULL && _shvec.size() > 0 )