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

0027700: Visualization - glPolygonMode() used for frame drawing affects label text shading

Patch extends GL-state caching mechanism of OpenGl_Context by new methods.
The methods allow setting/inquiring polygon rasterization and hatching modes:
- OpenGl_Context::SetPolygonMode
- OpenGl_Context::SetPolygonHatchEnabled
- OpenGl_Context::SetPolygonHatchStyle

With these methods OpenGl_Text is able to configure shading as necessary.
And this configuration is done irrespectively of currently defined face aspect.
Code of OpenGl_Workspace is also modified to use these methods as well.

Porting notes:
- OpenGl_LineAttributes now require OpenGl_Context instance for calling GL API.
- OpenGl_LineAttributes has new flag IsEnabled, it turns on/off hatching without changing the hatch type.
  By default this flag is turned on and can be never modified for compatibility with old code.
- OpenGl_LineAttributes is not anymore a field of OpenGl_Workspace::myLineAttrib.
  This resource is directly created by an OpenGl_Context instance on demand.
  If you use custom implementation of hatch patterns please create and share custom resource
  under resource-key "OpenGl_LineAttributes" in corresponding OpenGl_Context before using
  methods SetPolygonHatchEnabled, SetPolygonHatchStyle.
This commit is contained in:
apl
2016-08-01 22:09:20 +03:00
committed by bugmaster
parent d509e5a43f
commit 6d0e6be5a2
9 changed files with 352 additions and 108 deletions

View File

@@ -141,9 +141,11 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
#if !defined(GL_ES_VERSION_2_0)
myPointSpriteOrig (GL_UPPER_LEFT),
myRenderMode (GL_RENDER),
myPolygonMode (GL_FILL),
#else
myPointSpriteOrig (0),
myRenderMode (0),
myPolygonMode (0),
#endif
myToCullBackFaces (false),
myReadBuffer (0),
@@ -2844,6 +2846,70 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl
return anOldGlNormalize;
}
// =======================================================================
// function : SetPolygonMode
// purpose :
// =======================================================================
Standard_Integer OpenGl_Context::SetPolygonMode (const Standard_Integer theMode)
{
if (myPolygonMode == theMode)
{
return myPolygonMode;
}
const Standard_Integer anOldPolygonMode = myPolygonMode;
myPolygonMode = theMode;
#if !defined(GL_ES_VERSION_2_0)
::glPolygonMode (GL_FRONT_AND_BACK, (GLenum)theMode);
#endif
return anOldPolygonMode;
}
// =======================================================================
// function : SetPolygonHatchEnabled
// purpose :
// =======================================================================
bool OpenGl_Context::SetPolygonHatchEnabled (const bool theIsEnabled)
{
if (myHatchStyles.IsNull())
{
return false;
}
else if (myHatchStyles->IsEnabled() == theIsEnabled)
{
return theIsEnabled;
}
return myHatchStyles->SetEnabled (this, theIsEnabled);
}
// =======================================================================
// function : SetPolygonHatchStyle
// purpose :
// =======================================================================
Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Standard_Integer theType)
{
if (myHatchStyles.IsNull())
{
if (!GetResource ("OpenGl_LineAttributes", myHatchStyles))
{
// share and register for release once the resource is no longer used
myHatchStyles = new OpenGl_LineAttributes();
ShareResource ("OpenGl_LineAttributes", myHatchStyles);
myHatchStyles->Init (this);
}
}
if (myHatchStyles->TypeOfHatch() == theType)
{
return theType;
}
return myHatchStyles->SetTypeOfHatch (this, theType);
}
// =======================================================================
// function : ApplyModelWorldMatrix
// purpose :