diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index f2c1ab26d..feef49875 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -250,6 +250,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced const osg::Matrix computeMVPW() const; + void clearArea(int x,int y,int width,int height,const osg::Vec4& color); + osg::ref_ptr _sceneData; osg::ref_ptr _globalState; osg::ref_ptr _light; diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index 74aba9c40..4cb67e15d 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -64,13 +64,15 @@ void RenderStage::draw(osg::State& state,RenderLeaf*& previous) // set up the back buffer. + //state.applyAttribute(_viewport.get()); + _viewport->apply(state); + #define USE_SISSOR_TEST #ifdef USE_SISSOR_TEST glScissor( _viewport->x(), _viewport->y(), _viewport->width(), _viewport->height() ); glEnable( GL_SCISSOR_TEST ); #endif - _viewport->apply(state); // glEnable( GL_DEPTH_TEST ); diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 941db79dd..847c77f7f 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -452,6 +452,9 @@ void SceneView::draw() osg::ref_ptr viewportRight = osgNew osg::Viewport; viewportRight->setViewport(_viewport->x()+right_half_begin,_viewport->y(),right_half_width,_viewport->height()); + + clearArea(_viewport->x()+left_half_width,_viewport->y(),seperation,_viewport->height(),_renderStageLeft->getClearColor()); + if (_displaySettings->getSplitStereoHorizontalEyeMapping()==osg::DisplaySettings::LEFT_EYE_LEFT_VIEWPORT) { _renderStageLeft->setViewport(viewportLeft.get()); @@ -486,6 +489,8 @@ void SceneView::draw() osg::ref_ptr viewportBottom = osgNew osg::Viewport; viewportBottom->setViewport(_viewport->x(),_viewport->y(),_viewport->width(),bottom_half_height); + clearArea(_viewport->x(),_viewport->y()+bottom_half_height,_viewport->width(),seperation,_renderStageLeft->getClearColor()); + if (_displaySettings->getSplitStereoVerticalEyeMapping()==osg::DisplaySettings::LEFT_EYE_TOP_VIEWPORT) { _renderStageLeft->setViewport(viewportTop.get()); @@ -608,3 +613,18 @@ const osg::Matrix SceneView::computeMVPW() const return matrix; } + +void SceneView::clearArea(int x,int y,int width,int height,const osg::Vec4& color) +{ + osg::ref_ptr viewport = osgNew osg::Viewport; + viewport->setViewport(x,y,width,height); + + viewport->apply(*_state); + + glScissor( x, y, width, height ); + glEnable( GL_SCISSOR_TEST ); + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + glClearColor( color[0], color[1], color[2], color[3]); + glClear( GL_COLOR_BUFFER_BIT); + glDisable( GL_SCISSOR_TEST ); +}