1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

Fix grid flickering

This commit is contained in:
mzernova 2024-11-22 12:47:20 +00:00
parent b10301d109
commit 2a1fa7be50
2 changed files with 12 additions and 3 deletions

View File

@ -2280,7 +2280,8 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
EOL" aColor.a *= aFading;"
EOL" }"
EOL" gl_FragDepth = uIsBackground ? 1.0 : min (aDepth, 1.0);"
EOL" float aMaxDepth = 1.0 - 1e-5;"
EOL" gl_FragDepth = uIsBackground ? aMaxDepth : min (aDepth, aMaxDepth);"
EOL" occFragColor = aColor;"
EOL"}";

View File

@ -2597,10 +2597,14 @@ void OpenGl_View::renderGrid()
aContext->ApplyWorldViewMatrix();
aContext->core11fwd->glEnable (GL_DEPTH_TEST);
aContext->core11fwd->glDepthFunc (GL_LEQUAL);
aContext->core11fwd->glDepthFunc (GL_LESS);
aContext->core11fwd->glDepthMask (GL_TRUE);
aContext->core11fwd->glEnable (GL_BLEND);
aContext->core20fwd->glBlendFuncSeparate (GL_SRC_ALPHA, GL_DST_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
const bool wasDepthClamped = aContext->arbDepthClamp && aContext->core11fwd->glIsEnabled (GL_DEPTH_CLAMP);
if (aContext->arbDepthClamp && !wasDepthClamped)
{
aContext->core11fwd->glEnable (GL_DEPTH_CLAMP);
}
const Standard_Real aCameraScale = aContext->Camera()->Scale();
Standard_Real aScale = myGridParams.IsInfinity()
@ -2625,6 +2629,10 @@ void OpenGl_View::renderGrid()
aContext->Camera()->SetZRange (aZNear, aZFar);
aContext->Camera()->SetProjectionType (aProjectionType);
aContext->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (aContext->arbDepthClamp && !wasDepthClamped)
{
aContext->core11fwd->glDisable (GL_DEPTH_CLAMP);
}
aContext->WorldViewState.Pop();
aContext->ProjectionState.Pop();