mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
Fix grid flickering
This commit is contained in:
parent
6bb681d269
commit
b10301d109
@ -2280,7 +2280,7 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
|
|||||||
EOL" aColor.a *= aFading;"
|
EOL" aColor.a *= aFading;"
|
||||||
EOL" }"
|
EOL" }"
|
||||||
|
|
||||||
EOL" gl_FragDepth = uIsBackground ? aFar - 0.001 : min (aDepth, aFar - 0.001);"
|
EOL" gl_FragDepth = uIsBackground ? 1.0 : min (aDepth, 1.0);"
|
||||||
EOL" occFragColor = aColor;"
|
EOL" occFragColor = aColor;"
|
||||||
EOL"}";
|
EOL"}";
|
||||||
|
|
||||||
|
@ -2565,8 +2565,11 @@ void OpenGl_View::renderGrid()
|
|||||||
const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
|
||||||
|
|
||||||
Bnd_Box aBnd = MinMaxValues (Standard_True);
|
Bnd_Box aBnd = MinMaxValues (Standard_True);
|
||||||
aBnd.Add (myGridParams.Position());
|
if (myGridParams.IsBackground() || aBnd.IsOut (myGridParams.Position()))
|
||||||
aContext->Camera()->ZFitAll (1.0, aBnd, aBnd);
|
{
|
||||||
|
aBnd.Add (myGridParams.Position());
|
||||||
|
aContext->Camera()->ZFitAll (1.0, aBnd, aBnd);
|
||||||
|
}
|
||||||
|
|
||||||
const Standard_Real aZNear = aContext->Camera()->ZNear();
|
const Standard_Real aZNear = aContext->Camera()->ZNear();
|
||||||
const Standard_Real aZFar = aContext->Camera()->ZFar();
|
const Standard_Real aZFar = aContext->Camera()->ZFar();
|
||||||
@ -2586,7 +2589,7 @@ void OpenGl_View::renderGrid()
|
|||||||
? OpenGl_Mat4()
|
? OpenGl_Mat4()
|
||||||
: aContext->WorldViewState.Current();
|
: aContext->WorldViewState.Current();
|
||||||
OpenGl_Mat4 aMat;
|
OpenGl_Mat4 aMat;
|
||||||
const gp_Pnt& aPosition = myGridParams.Position();
|
const gp_Pnt& aPosition = myGridParams.IsBackground() ? gp_Pnt (0.0, 0.0, -aZFar) : myGridParams.Position();
|
||||||
aMat.SetColumn (3, Graphic3d_Vec4 ((float)aPosition.X(), (float)aPosition.Y(), (float)aPosition.Z(), 1.0));
|
aMat.SetColumn (3, Graphic3d_Vec4 ((float)aPosition.X(), (float)aPosition.Y(), (float)aPosition.Z(), 1.0));
|
||||||
|
|
||||||
aContext->WorldViewState.Push();
|
aContext->WorldViewState.Push();
|
||||||
@ -2594,9 +2597,10 @@ void OpenGl_View::renderGrid()
|
|||||||
aContext->ApplyWorldViewMatrix();
|
aContext->ApplyWorldViewMatrix();
|
||||||
|
|
||||||
aContext->core11fwd->glEnable (GL_DEPTH_TEST);
|
aContext->core11fwd->glEnable (GL_DEPTH_TEST);
|
||||||
aContext->core11fwd->glDepthFunc (GL_LESS);
|
aContext->core11fwd->glDepthFunc (GL_LEQUAL);
|
||||||
|
aContext->core11fwd->glDepthMask (GL_TRUE);
|
||||||
aContext->core11fwd->glEnable (GL_BLEND);
|
aContext->core11fwd->glEnable (GL_BLEND);
|
||||||
aContext->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
aContext->core20fwd->glBlendFuncSeparate (GL_SRC_ALPHA, GL_DST_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
const Standard_Real aCameraScale = aContext->Camera()->Scale();
|
const Standard_Real aCameraScale = aContext->Camera()->Scale();
|
||||||
Standard_Real aScale = myGridParams.IsInfinity()
|
Standard_Real aScale = myGridParams.IsInfinity()
|
||||||
@ -2620,6 +2624,7 @@ void OpenGl_View::renderGrid()
|
|||||||
|
|
||||||
aContext->Camera()->SetZRange (aZNear, aZFar);
|
aContext->Camera()->SetZRange (aZNear, aZFar);
|
||||||
aContext->Camera()->SetProjectionType (aProjectionType);
|
aContext->Camera()->SetProjectionType (aProjectionType);
|
||||||
|
aContext->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
aContext->WorldViewState.Pop();
|
aContext->WorldViewState.Pop();
|
||||||
aContext->ProjectionState.Pop();
|
aContext->ProjectionState.Pop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user