diff --git a/src/OpenGl/OpenGl_FrameStatsPrs.cxx b/src/OpenGl/OpenGl_FrameStatsPrs.cxx index b57e6ed613..8213867c66 100644 --- a/src/OpenGl/OpenGl_FrameStatsPrs.cxx +++ b/src/OpenGl/OpenGl_FrameStatsPrs.cxx @@ -380,6 +380,11 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) theWorkspace->UseDepthWrite() = Standard_False; aCtx->core11fwd->glDepthMask (GL_FALSE); } + const bool wasDepthClamped = aCtx->arbDepthClamp && aCtx->core11fwd->glIsEnabled (GL_DEPTH_CLAMP); + if (aCtx->arbDepthClamp && !wasDepthClamped) + { + aCtx->core11fwd->glEnable (GL_DEPTH_CLAMP); + } const OpenGl_Aspects* aTextAspectBack = theWorkspace->SetAspects (&myTextAspect); @@ -455,6 +460,10 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) theWorkspace->UseDepthWrite() = wasEnabledDepth; aCtx->core11fwd->glDepthMask (wasEnabledDepth ? GL_TRUE : GL_FALSE); } + if (aCtx->arbDepthClamp && !wasDepthClamped) + { + aCtx->core11fwd->glDisable (GL_DEPTH_CLAMP); + } } // ======================================================================= diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index 95cb7dcdaf..819491c3e6 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -787,6 +787,15 @@ Bnd_Box OpenGl_View::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) Bnd_Box aBox = base_type::MinMaxValues (theToIncludeAuxiliary); + // make sure that stats overlay isn't clamped on hardware with unavailable depth clamping + if (myRenderParams.ToShowStats && !myWorkspace->GetGlContext()->arbDepthClamp) + { + Bnd_Box aStatsBox (gp_Pnt (float(myWindow->Width() / 2.0), float(myWindow->Height() / 2.0), 0.0), + gp_Pnt (float(myWindow->Width() / 2.0), float(myWindow->Height() / 2.0), 0.0)); + myRenderParams.StatsPosition->Apply (myCamera, myCamera->ProjectionMatrix(), myCamera->OrientationMatrix(), + myWindow->Width(), myWindow->Height(), aStatsBox); + aBox.Add (aStatsBox); + } return aBox; } diff --git a/tests/opengl/data/general/bug32722 b/tests/opengl/data/general/bug32722 new file mode 100644 index 0000000000..4d4b9301b3 --- /dev/null +++ b/tests/opengl/data/general/bug32722 @@ -0,0 +1,19 @@ +puts "========" +puts "OCC32722: Visualization, TKOpenGl - performance counters disappear at some camera viewpoints" +puts "========" +puts "" + +pload MODELING VISUALIZATION +vinit View1 +vcamera -persp + +box b1 0 0 0 50 50 50 +box b2 150 0 0 50 50 50 +box b3 0 150 0 50 50 50 +vdisplay b1 b2 b3 -dispMode 1 -noupdate +vaspects b1 b2 b3 -color RED -transparency 0.5 + +vrenderparams -perfCounters fps +vviewparams -scale 2.14747 -proj 0.160074 0.265291 -0.950788 -up -0.0189965 0.963858 0.265739 -at 63.0574 214.479 199.417 +checkcolor 22 34 0.8 0.8 0.8 +vdump $::imagedir/${::casename}.png