1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0029366: Visualization, OpenGl_Text - artifacts when using Aspect_TODT_SHADOW/Aspect_TODT_DEKALE at different zoom level

OpenGl_Text now applies Polygon Offset instead of Z-shift in world coordinates for drawing background.
OpenGl_Context::SetPolygonOffset() - polygon offset state has been moved from OpenGl_Workspace to OpenGl_Context.
This commit is contained in:
kgv
2017-12-04 16:29:43 +03:00
committed by bugmaster
parent faaa95cbe7
commit 8d1a539c4a
6 changed files with 126 additions and 74 deletions

View File

@@ -207,6 +207,10 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
myViewportVirt[2] = 0;
myViewportVirt[3] = 0;
myPolygonOffset.Mode = Aspect_POM_Off;
myPolygonOffset.Factor = 0.0f;
myPolygonOffset.Units = 0.0f;
// system-dependent fields
#if defined(HAVE_EGL)
myDisplay = (Aspect_Display )EGL_NO_DISPLAY;
@@ -3558,6 +3562,64 @@ Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Handle(Graphic3d_Ha
return myHatchStyles->SetTypeOfHatch (this, theStyle);
}
// =======================================================================
// function : SetPolygonOffset
// purpose :
// =======================================================================
void OpenGl_Context::SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
{
const bool toFillOld = (myPolygonOffset.Mode & Aspect_POM_Fill) == Aspect_POM_Fill;
const bool toFillNew = (theOffset.Mode & Aspect_POM_Fill) == Aspect_POM_Fill;
if (toFillNew != toFillOld)
{
if (toFillNew)
{
glEnable (GL_POLYGON_OFFSET_FILL);
}
else
{
glDisable (GL_POLYGON_OFFSET_FILL);
}
}
#if !defined(GL_ES_VERSION_2_0)
const bool toLineOld = (myPolygonOffset.Mode & Aspect_POM_Line) == Aspect_POM_Line;
const bool toLineNew = (theOffset.Mode & Aspect_POM_Line) == Aspect_POM_Line;
if (toLineNew != toLineOld)
{
if (toLineNew)
{
glEnable (GL_POLYGON_OFFSET_LINE);
}
else
{
glDisable (GL_POLYGON_OFFSET_LINE);
}
}
const bool toPointOld = (myPolygonOffset.Mode & Aspect_POM_Point) == Aspect_POM_Point;
const bool toPointNew = (theOffset.Mode & Aspect_POM_Point) == Aspect_POM_Point;
if (toPointNew != toPointOld)
{
if (toPointNew)
{
glEnable (GL_POLYGON_OFFSET_POINT);
}
else
{
glDisable (GL_POLYGON_OFFSET_POINT);
}
}
#endif
if (myPolygonOffset.Factor != theOffset.Factor
|| myPolygonOffset.Units != theOffset.Units)
{
glPolygonOffset (theOffset.Factor, theOffset.Units);
}
myPolygonOffset = theOffset;
}
// =======================================================================
// function : ApplyModelWorldMatrix
// purpose :