From f79f4654677714579e841462b7eae4352b3eb4f6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 24 Nov 2009 14:32:51 +0000 Subject: [PATCH] From Farshid Lashkari, "I've attached a small fix to osgUtil::SceneView so that is uses a scissor test when clearing the stencil buffer for stencil based stereo." and "I've added another small change for stencil based stereo, so please use this newer version. This newer version simplifies the calls to glOrtho and glRecti when drawing the stipple pattern. This change also happens to fix an issue where the stencil stereo would not work with certain viewport settings. I'm not exactly sure why this was happening, it might be a graphics driver issue, but either way I think the changes should be fine." --- src/osgUtil/SceneView.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 18a9a9111..00ac12fea 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -1329,7 +1329,7 @@ void SceneView::draw() state->applyProjectionMatrix(0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(getViewport()->x(), getViewport()->width(), getViewport()->y(), getViewport()->height(), -1.0, 1.0); + glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -1337,7 +1337,10 @@ void SceneView::draw() getState()->applyMode(GL_LIGHTING,false); getState()->applyMode(GL_DEPTH_TEST,false); glStencilMask(~0u); + glScissor( getViewport()->x(), getViewport()->y(), getViewport()->width(), getViewport()->height() ); + glEnable( GL_SCISSOR_TEST ); glClear(GL_STENCIL_BUFFER_BIT); + glDisable( GL_SCISSOR_TEST ); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); glStencilFunc(GL_ALWAYS, 1, ~0u); if(_displaySettings->getStereoMode() == osg::DisplaySettings::VERTICAL_INTERLACE) @@ -1354,12 +1357,7 @@ void SceneView::draw() } getState()->applyMode(GL_POLYGON_STIPPLE,true); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - - glRecti(static_cast(getViewport()->x()), - static_cast(getViewport()->y()), - static_cast(getViewport()->width()), - static_cast(getViewport()->height()) ); - + glRecti(0, 0, 1, 1); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); getState()->applyMode(GL_POLYGON_STIPPLE,false); getState()->applyMode(GL_LIGHTING,true);