mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0029974: Visualization - OpenGl_Layer::Render() produces inconsistent state of Polygon Offset settings
OpenGl_Layer::Render() now calls OpenGl_Workspace::SetDefaultPolygonOffset() for managing default polygon offset settings considering OpenGl_Workspace applied aspect logic.
This commit is contained in:
parent
9427bc1d1e
commit
a6df1715ed
@ -214,6 +214,9 @@ public:
|
|||||||
//! Returns current polygon offsets settings.
|
//! Returns current polygon offsets settings.
|
||||||
const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
|
const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
|
||||||
|
|
||||||
|
//! Sets polygon offsets settings.
|
||||||
|
void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; }
|
||||||
|
|
||||||
//! Returns current polygon offsets settings.
|
//! Returns current polygon offsets settings.
|
||||||
void PolygonOffsets (Standard_Integer& theMode,
|
void PolygonOffsets (Standard_Integer& theMode,
|
||||||
Standard_ShortReal& theFactor,
|
Standard_ShortReal& theFactor,
|
||||||
|
@ -656,7 +656,6 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
|||||||
const OpenGl_GlobalLayerSettings& theDefaultSettings) const
|
const OpenGl_GlobalLayerSettings& theDefaultSettings) const
|
||||||
{
|
{
|
||||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||||
const Graphic3d_PolygonOffset anAppliedOffsetParams = aCtx->PolygonOffset();
|
|
||||||
// myLayerSettings.ToClearDepth() is handled outside
|
// myLayerSettings.ToClearDepth() is handled outside
|
||||||
|
|
||||||
// handle depth test
|
// handle depth test
|
||||||
@ -678,7 +677,7 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle depth offset
|
// handle depth offset
|
||||||
aCtx->SetPolygonOffset (myLayerSettings.PolygonOffset());
|
const Graphic3d_PolygonOffset anAppliedOffsetParams = theWorkspace->SetDefaultPolygonOffset (myLayerSettings.PolygonOffset());
|
||||||
|
|
||||||
// handle depth write
|
// handle depth write
|
||||||
theWorkspace->UseDepthWrite() = myLayerSettings.ToEnableDepthWrite() && theDefaultSettings.DepthMask == GL_TRUE;
|
theWorkspace->UseDepthWrite() = myLayerSettings.ToEnableDepthWrite() && theDefaultSettings.DepthMask == GL_TRUE;
|
||||||
@ -759,7 +758,7 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// always restore polygon offset between layers rendering
|
// always restore polygon offset between layers rendering
|
||||||
aCtx->SetPolygonOffset (anAppliedOffsetParams);
|
theWorkspace->SetDefaultPolygonOffset (anAppliedOffsetParams);
|
||||||
|
|
||||||
// restore environment texture
|
// restore environment texture
|
||||||
if (!myLayerSettings.UseEnvironmentTexture())
|
if (!myLayerSettings.UseEnvironmentTexture())
|
||||||
|
@ -43,11 +43,6 @@ namespace
|
|||||||
static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f);
|
static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f);
|
static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
static const OpenGl_AspectLine myDefaultAspectLine;
|
|
||||||
static const OpenGl_AspectFace myDefaultAspectFace;
|
|
||||||
static const OpenGl_AspectMarker myDefaultAspectMarker;
|
|
||||||
static const OpenGl_AspectText myDefaultAspectText;
|
|
||||||
|
|
||||||
static const OpenGl_Matrix myDefaultMatrix =
|
static const OpenGl_Matrix myDefaultMatrix =
|
||||||
{
|
{
|
||||||
{{ 1.0F, 0.0F, 0.0F, 0.0F },
|
{{ 1.0F, 0.0F, 0.0F, 0.0F },
|
||||||
@ -228,6 +223,23 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
|||||||
myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
|
myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : SetDefaultPolygonOffset
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
|
||||||
|
{
|
||||||
|
Graphic3d_PolygonOffset aPrev = myDefaultAspectFace.Aspect()->PolygonOffset();
|
||||||
|
myDefaultAspectFace.Aspect()->SetPolygonOffset (theOffset);
|
||||||
|
if (myAspectFaceApplied == myDefaultAspectFace.Aspect()
|
||||||
|
|| myAspectFaceApplied.IsNull()
|
||||||
|
|| (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
|
||||||
|
{
|
||||||
|
myGlContext->SetPolygonOffset (theOffset);
|
||||||
|
}
|
||||||
|
return aPrev;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : SetAspectLine
|
// function : SetAspectLine
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -86,6 +86,10 @@ public:
|
|||||||
//! @return true if frustum culling algorithm is enabled
|
//! @return true if frustum culling algorithm is enabled
|
||||||
Standard_EXPORT Standard_Boolean IsCullingEnabled() const;
|
Standard_EXPORT Standard_Boolean IsCullingEnabled() const;
|
||||||
|
|
||||||
|
//! Configure default polygon offset parameters.
|
||||||
|
//! Return previous settings.
|
||||||
|
Standard_EXPORT Graphic3d_PolygonOffset SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset);
|
||||||
|
|
||||||
//// RELATED TO STATUS ////
|
//// RELATED TO STATUS ////
|
||||||
|
|
||||||
//! Return true if active group might activate face culling (e.g. primitives are closed).
|
//! Return true if active group might activate face culling (e.g. primitives are closed).
|
||||||
@ -259,6 +263,11 @@ protected: //! @name fields related to status
|
|||||||
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
|
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
|
||||||
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
|
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
|
||||||
|
|
||||||
|
OpenGl_AspectLine myDefaultAspectLine;
|
||||||
|
OpenGl_AspectFace myDefaultAspectFace;
|
||||||
|
OpenGl_AspectMarker myDefaultAspectMarker;
|
||||||
|
OpenGl_AspectText myDefaultAspectText;
|
||||||
|
|
||||||
const OpenGl_AspectLine* myAspectLineSet;
|
const OpenGl_AspectLine* myAspectLineSet;
|
||||||
const OpenGl_AspectFace* myAspectFaceSet;
|
const OpenGl_AspectFace* myAspectFaceSet;
|
||||||
Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
|
Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user