diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index a10c11755..138bb0cb3 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -190,6 +190,17 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced /** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */ void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up); + /** Set the draw buffer value used at the start of each frame draw. Note, overridden in quad buffer stereo mode */ + void setDrawBufferValue( GLenum drawBufferValue ) + { + _drawBufferValue = drawBufferValue; + } + + /** Get the draw buffer value used at the start of each frame draw. */ + GLenum getDrawBufferValue() const + { + return _drawBufferValue; + } /** Get the view matrix. */ osg::Matrixd& getViewMatrix() { return _viewMatrix; } @@ -296,10 +307,10 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced /** Set the FusionDistanceMode and Value. Note, is used only when working in stereo.*/ void setFusionDistance(FusionDistanceMode mode,float value=1.0f) - { - _fusionDistanceMode = mode; - _fusionDistanceValue = value; - } + { + _fusionDistanceMode = mode; + _fusionDistanceValue = value; + } /** Get the FusionDistanceMode.*/ FusionDistanceMode getFusionDistanceMode() const { return _fusionDistanceMode; } @@ -472,6 +483,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced bool _prioritizeTextures; + GLenum _drawBufferValue; + }; } diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 25e041aba..3bb4a74d1 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -56,6 +56,8 @@ SceneView::SceneView(DisplaySettings* ds) _cullMask = 0xffffffff; _cullMaskLeft = 0xffffffff; _cullMaskRight = 0xffffffff; + + _drawBufferValue = GL_BACK; } @@ -640,6 +642,10 @@ void SceneView::draw() break; case(osg::DisplaySettings::ANAGLYPHIC): { + if( _drawBufferValue != GL_NONE) + { + glDrawBuffer(_drawBufferValue); + } _localStateSet->setAttribute(_viewport.get()); @@ -687,6 +693,11 @@ void SceneView::draw() break; case(osg::DisplaySettings::HORIZONTAL_SPLIT): { + if( _drawBufferValue != GL_NONE) + { + glDrawBuffer(_drawBufferValue); + } + // ensure that all color planes are active. osg::ColorMask* cmask = static_cast(_localStateSet->getAttribute(osg::StateAttribute::COLORMASK)); if (cmask) @@ -744,6 +755,11 @@ void SceneView::draw() break; case(osg::DisplaySettings::VERTICAL_SPLIT): { + if( _drawBufferValue != GL_NONE) + { + glDrawBuffer(_drawBufferValue); + } + // ensure that all color planes are active. osg::ColorMask* cmask = static_cast(_localStateSet->getAttribute(osg::StateAttribute::COLORMASK)); if (cmask) @@ -800,6 +816,11 @@ void SceneView::draw() case(osg::DisplaySettings::RIGHT_EYE): case(osg::DisplaySettings::LEFT_EYE): { + if( _drawBufferValue != GL_NONE) + { + glDrawBuffer(_drawBufferValue); + } + // ensure that all color planes are active. osg::ColorMask* cmask = static_cast(_localStateSet->getAttribute(osg::StateAttribute::COLORMASK)); if (cmask) @@ -829,8 +850,11 @@ void SceneView::draw() else { - // Need to restore draw buffer when toggling Stereo off. - glDrawBuffer(GL_BACK); + // Need to restore draw buffer when toggling Stereo off. + if( _drawBufferValue != GL_NONE) + { + glDrawBuffer(_drawBufferValue); + } _localStateSet->setAttribute(_viewport.get());