Skip to content

Commit

Permalink
Merged changed from svn/trunk, improving the reliability of the clear…
Browse files Browse the repository at this point in the history
… of the stencil and depth buffer.
  • Loading branch information
robertosfield committed May 18, 2009
1 parent f3676d1 commit 297003a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/osgUtil/RenderStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,17 +1202,12 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
// set up the back buffer.
state.applyAttribute(_viewport.get());

#define USE_SISSOR_TEST
#ifdef USE_SISSOR_TEST
glScissor( static_cast<int>(_viewport->x()),
static_cast<int>(_viewport->y()),
static_cast<int>(_viewport->width()),
static_cast<int>(_viewport->height()) );
//cout << " clearing "<<this<< " "<<_viewport->x()<<","<< _viewport->y()<<","<< _viewport->width()<<","<< _viewport->height()<<std::endl;

glEnable( GL_SCISSOR_TEST );
#endif

state.applyMode( GL_SCISSOR_TEST, true );

// glEnable( GL_DEPTH_TEST );

Expand All @@ -1221,21 +1216,33 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
else glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

if (_clearMask & GL_COLOR_BUFFER_BIT)
{
glClearColor( _clearColor[0], _clearColor[1], _clearColor[2], _clearColor[3]);
}

if (_clearMask & GL_DEPTH_BUFFER_BIT)
{
glClearDepth( _clearDepth);
glDepthMask ( GL_TRUE );
state.haveAppliedAttribute( osg::StateAttribute::DEPTH );
}

if (_clearMask & GL_STENCIL_BUFFER_BIT)
{
glClearStencil( _clearStencil);
glStencilMask ( GL_TRUE );
state.haveAppliedAttribute( osg::StateAttribute::STENCIL );
}

if (_clearMask & GL_ACCUM_BUFFER_BIT)
{
glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]);
}


glClear( _clearMask );

#ifdef USE_SISSOR_TEST
#ifdef USE_SCISSOR_TEST
glDisable( GL_SCISSOR_TEST );
#endif

Expand Down

0 comments on commit 297003a

Please sign in to comment.