If specific layer setting is not enabled, default value extracted from current OpenGl state will be used.
Default value fix.
Updated test case bugs/vis/bug24867
Linux warning fixed.
{{ 1.0F, 1.0F, 1.0F, 1.0F }} // material color
};
- static TEL_POFFSET_PARAM THE_DEFAULT_POFFSET = { Aspect_POM_Fill, 1.0F, 0.0F };
static const TCollection_AsciiString THE_EMPTY_KEY;
};
#include <InterfaceGraphic_telem.hxx>
#include <Aspect_InteriorStyle.hxx>
+#include <Aspect_PolygonOffsetMode.hxx>
#include <TCollection_AsciiString.hxx>
#include <Handle_Graphic3d_TextureParams.hxx>
#define OPENGL_SPECULAR_MASK (1<<2)
#define OPENGL_EMISSIVE_MASK (1<<3)
+static const TEL_POFFSET_PARAM THE_DEFAULT_POFFSET = { Aspect_POM_Fill, 1.0F, 0.0F };
+
struct OPENGL_SURF_PROP
{
float amb, diff, spec, emsv;
// commercial license or contractual agreement.
#include <OpenGl_Layer.hxx>
-
+#include <OpenGl_Workspace.hxx>
#include <OpenGl_GlCore11.hxx>
//=======================================================================
//function : Render
//purpose :
//=======================================================================
-void OpenGl_Layer::Render (const Handle(OpenGl_Workspace) &AWorkspace, int theDefaultDepthFunc) const
+void OpenGl_Layer::Render (const Handle(OpenGl_Workspace) &theWorkspace, const OpenGl_GlobalLayerSettings& theDefaultSettings) const
{
+ TEL_POFFSET_PARAM anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset();
+
// separate depth buffers
if (IsSettingEnabled (Graphic3d_ZLayerDepthClear))
{
glClear (GL_DEPTH_BUFFER_BIT);
}
-
+
// handle depth test
if (IsSettingEnabled (Graphic3d_ZLayerDepthTest))
{
- glDepthFunc (theDefaultDepthFunc);
+ // assuming depth test is enabled by default
+ glDepthFunc (theDefaultSettings.DepthFunc);
}
else
{
glDepthFunc (GL_ALWAYS);
}
-
+
// handle depth offset
if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset))
{
- glPolygonOffset (myLayerSettings.DepthOffsetFactor, myLayerSettings.DepthOffsetUnits);
+ theWorkspace->SetPolygonOffset (Aspect_POM_Fill,
+ myLayerSettings.DepthOffsetFactor,
+ myLayerSettings.DepthOffsetUnits);
}
else
{
- glPolygonOffset (0.0f, 0.0f);
+ theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
+ anAppliedOffsetParams.factor,
+ anAppliedOffsetParams.units);
}
// handle depth write
}
// render priority list
- myPriorityList.Render (AWorkspace);
+ myPriorityList.Render (theWorkspace);
+
+ // always restore polygon offset between layers rendering
+ theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
+ anAppliedOffsetParams.factor,
+ anAppliedOffsetParams.units);
}
#include <OpenGl_PriorityList.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
+#include <OpenGl_GlCore11.hxx>
class Handle(OpenGl_Workspace);
+struct OpenGl_GlobalLayerSettings
+{
+ GLint DepthFunc;
+ GLboolean DepthMask;
+};
+
class OpenGl_Layer
{
public:
//! Returns const reference to associated priority list.
const OpenGl_PriorityList& PriorityList() const { return myPriorityList; }
- void Render (const Handle(OpenGl_Workspace) &AWorkspace, int theDefaultDepthFunc) const;
+ void Render (const Handle(OpenGl_Workspace) &AWorkspace, const OpenGl_GlobalLayerSettings& theDefaultSettings) const;
private:
#include <OpenGl_LayerList.hxx>
#include <OpenGl_Structure.hxx>
+#include <OpenGl_Workspace.hxx>
#include <InterfaceGraphic_Graphic3d.hxx>
#include <InterfaceGraphic.hxx>
void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace) &theWorkspace) const
{
- int aDefaultDepthFunc;
- glGetIntegerv (GL_DEPTH_FUNC, &aDefaultDepthFunc);
+ OpenGl_GlobalLayerSettings aDefaultSettings;
+
+ glGetIntegerv (GL_DEPTH_FUNC, &aDefaultSettings.DepthFunc);
+ glGetBooleanv (GL_DEPTH_WRITEMASK, &aDefaultSettings.DepthMask);
OpenGl_SequenceOfLayers::Iterator anIts;
- for(anIts.Init (myLayers); anIts.More (); anIts.Next ())
+ for (anIts.Init (myLayers); anIts.More(); anIts.Next())
{
const OpenGl_Layer& aLayer = anIts.Value ();
if (aLayer.PriorityList().NbStructures () > 0)
{
// render layer
- aLayer.Render (theWorkspace, aDefaultDepthFunc);
+ aLayer.Render (theWorkspace, aDefaultSettings);
}
}
+
+ glDepthMask (aDefaultSettings.DepthMask);
+ glDepthFunc (aDefaultSettings.DepthFunc);
}
StructureMatrix_applied (&myDefaultMatrix),
myCullingMode (TelCullUndefined),
myModelViewMatrix (myDefaultMatrix),
- PolygonOffset_applied (NULL)
+ PolygonOffset_applied (THE_DEFAULT_POFFSET)
{
myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
AspectText_applied = NULL;
TextParam_set = &myDefaultTextParam;
TextParam_applied = NULL;
- PolygonOffset_applied = NULL;
+ PolygonOffset_applied = THE_DEFAULT_POFFSET;
myCullingMode = TelCullUndefined;
AspectLine(Standard_True);
#include <Aspect_CLayer2d.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_PrintAlgo.hxx>
+#include <Aspect_PolygonOffsetMode.hxx>
#include <InterfaceGraphic_Graphic3d.hxx>
#include <InterfaceGraphic_Visual3d.hxx>
//! @return applied model structure matrix.
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
+ //! Sets and applies current polygon offset.
+ void SetPolygonOffset (int theMode, Standard_ShortReal theFactor, Standard_ShortReal theUnits);
+
+ //! Returns currently applied polygon offset params.
+ const TEL_POFFSET_PARAM& AppliedPolygonOffset() { return PolygonOffset_applied; }
+
protected:
//! Copy content of Back buffer to the Front buffer
OpenGl_Material myMatTmp; //!< temporary variable
TelCullMode myCullingMode; //!< back face culling mode, applied from face aspect
- //! Model matrix with applied structure transformations
- OpenGl_Matrix myModelViewMatrix;
+ OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
- const TEL_POFFSET_PARAM* PolygonOffset_applied;
+ TEL_POFFSET_PARAM PolygonOffset_applied; //!< Currently applied polygon offset.
- OpenGl_AspectFace myAspectFaceHl; // Hiddenline aspect
+ OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
public: //! @name type definition
/*----------------------------------------------------------------------*/
-static void TelUpdatePolygonOffsets( const TEL_POFFSET_PARAM *pdata )
+static void TelUpdatePolygonOffsets (const TEL_POFFSET_PARAM& theOffsetData)
{
- if ( ( pdata->mode & Aspect_POM_Fill ) == Aspect_POM_Fill )
- glEnable ( GL_POLYGON_OFFSET_FILL );
+ if ((theOffsetData.mode & Aspect_POM_Fill) == Aspect_POM_Fill)
+ {
+ glEnable (GL_POLYGON_OFFSET_FILL);
+ }
else
- glDisable ( GL_POLYGON_OFFSET_FILL );
+ {
+ glDisable (GL_POLYGON_OFFSET_FILL);
+ }
- if ( ( pdata->mode & Aspect_POM_Line ) == Aspect_POM_Line )
- glEnable ( GL_POLYGON_OFFSET_LINE );
+ if ((theOffsetData.mode & Aspect_POM_Line) == Aspect_POM_Line)
+ {
+ glEnable (GL_POLYGON_OFFSET_LINE);
+ }
else
- glDisable( GL_POLYGON_OFFSET_LINE );
+ {
+ glDisable (GL_POLYGON_OFFSET_LINE);
+ }
- if ( ( pdata->mode & Aspect_POM_Point ) == Aspect_POM_Point )
- glEnable ( GL_POLYGON_OFFSET_POINT );
+ if ((theOffsetData.mode & Aspect_POM_Point) == Aspect_POM_Point)
+ {
+ glEnable (GL_POLYGON_OFFSET_POINT);
+ }
else
- glDisable( GL_POLYGON_OFFSET_POINT );
+ {
+ glDisable (GL_POLYGON_OFFSET_POINT);
+ }
- glPolygonOffset( pdata->factor, pdata->units );
+ glPolygonOffset (theOffsetData.factor, theOffsetData.units);
}
/*----------------------------------------------------------------------*/
// Aspect_POM_None means: do not change current settings
if ((AspectFace_set->PolygonOffset().mode & Aspect_POM_None) != Aspect_POM_None)
{
- if (PolygonOffset_applied == NULL
- || PolygonOffset_applied->mode != AspectFace_set->PolygonOffset().mode
- || PolygonOffset_applied->factor != AspectFace_set->PolygonOffset().factor
- || PolygonOffset_applied->units != AspectFace_set->PolygonOffset().units)
+ if (PolygonOffset_applied.mode != AspectFace_set->PolygonOffset().mode
+ || PolygonOffset_applied.factor != AspectFace_set->PolygonOffset().factor
+ || PolygonOffset_applied.units != AspectFace_set->PolygonOffset().units)
{
- PolygonOffset_applied = &AspectFace_set->PolygonOffset();
- TelUpdatePolygonOffsets (PolygonOffset_applied);
+ SetPolygonOffset (AspectFace_set->PolygonOffset().mode,
+ AspectFace_set->PolygonOffset().factor,
+ AspectFace_set->PolygonOffset().units);
}
}
return AspectFace_set;
}
+//=======================================================================
+//function : SetPolygonOffset
+//purpose :
+//=======================================================================
+void OpenGl_Workspace::SetPolygonOffset (int theMode,
+ Standard_ShortReal theFactor,
+ Standard_ShortReal theUnits)
+{
+ PolygonOffset_applied.mode = theMode;
+ PolygonOffset_applied.factor = theFactor;
+ PolygonOffset_applied.units = theUnits;
+
+ TelUpdatePolygonOffsets (PolygonOffset_applied);
+}
+
/*----------------------------------------------------------------------*/
const OpenGl_AspectMarker* OpenGl_Workspace::AspectMarker (const Standard_Boolean theToApply)
--- /dev/null
+puts "============"
+puts "OCC24867"
+puts "============"
+puts ""
+#############################################################
+# [Regression] Visualization - polygon offsets look broken
+#############################################################
+
+restore [locate_data_file Top.brep] b
+vinit View1
+vdisplay b
+vfit
+vsetdispmode 1
+vmoveto 200 200
+
+set x1_coord 264
+set y1_coord 288
+set x2_coord 251
+set y2_coord 271
+
+checkcolor $x1_coord $y1_coord 0 1 1
+if { $stat != 1 } {
+ puts "Error : Highlighting of dimension with flipping in local context failed."
+}
+
+checkcolor $x2_coord $y2_coord 0 1 1
+if { $stat != 1 } {
+ puts "Error : Highlighting of dimension with flipping in local context failed."
+}
+
+vdump $::imagedir/${::casename}_highlighted.png
+
+vselect 200 200
+vdump $::imagedir/${::casename}_selected.png
+