X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FOpenGl%2FOpenGl_LayerList.cxx;h=5f6c61973c4fa7e52da55fe5ade50418237765a5;hb=b3eab8efc324da6165d4219760edb0b890b62e78;hpb=5299b92ba1bb7aa468cfb4b2f09009ffa7bcdac1 diff --git a/src/OpenGl/OpenGl_LayerList.cxx b/src/OpenGl/OpenGl_LayerList.cxx index 588396f66c..5f6c61973c 100644 --- a/src/OpenGl/OpenGl_LayerList.cxx +++ b/src/OpenGl/OpenGl_LayerList.cxx @@ -387,6 +387,7 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace, aCtx->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &aDefaultSettings.DepthMask); Standard_Integer aSeqId = myLayers.Lower(); + bool toClearDepth = false; for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next(), ++aSeqId) { if (theLayersToProcess == OpenGl_LF_Bottom) @@ -403,29 +404,35 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace, } const OpenGl_Layer& aLayer = anIts.Value(); - if (aLayer.NbStructures() < 1) + if (aLayer.IsImmediate() != theToDrawImmediate) { continue; } - else if (theToDrawImmediate) + else if (aLayer.NbStructures() < 1) { - if (!aLayer.IsImmediate()) - { - continue; - } + // make sure to clear depth of previous layers even if layer has no structures + toClearDepth = toClearDepth || aLayer.LayerSettings().ToClearDepth(); + continue; } - else + + // depth buffers + if (toClearDepth + || aLayer.LayerSettings().ToClearDepth()) { - if (aLayer.IsImmediate()) - { - continue; - } + toClearDepth = false; + glDepthMask (GL_TRUE); + glClear (GL_DEPTH_BUFFER_BIT); } - // render layer aLayer.Render (theWorkspace, aDefaultSettings); } + if (toClearDepth) + { + glDepthMask (GL_TRUE); + glClear (GL_DEPTH_BUFFER_BIT); + } + aCtx->core11fwd->glDepthMask (aDefaultSettings.DepthMask); aCtx->core11fwd->glDepthFunc (aDefaultSettings.DepthFunc); }