0025060: Capping breaks highlighting of shaded AIS_Shape with displayed edges
authorapl <apl@opencascade.com>
Thu, 10 Jul 2014 09:06:13 +0000 (13:06 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 17 Jul 2014 07:23:21 +0000 (11:23 +0400)
Capping algorithm - remember and restore depth function mode.

src/OpenGl/OpenGl_CappingAlgo.cxx
tests/bugs/vis/bug25060 [new file with mode: 0644]

index 5431534..d0bdb57 100755 (executable)
@@ -103,6 +103,12 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)&  theWork
   // prepare for rendering the clip planes
   glEnable (GL_STENCIL_TEST);
 
+  // remember current state of depth
+  // function and change its value
+  GLint aDepthFuncPrev;
+  glGetIntegerv (GL_DEPTH_FUNC, &aDepthFuncPrev);
+  glDepthFunc (GL_LESS);
+
   // generate capping for every clip plane
   for (aCappingIt.Init (aContextPlanes); aCappingIt.More(); aCappingIt.Next())
   {
@@ -158,7 +164,6 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)&  theWork
     // render capping plane using the generated stencil mask
     glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
     glDepthMask (GL_TRUE);
-    glDepthFunc (GL_LESS);
     glStencilFunc (GL_EQUAL, 1, 0x01);
     glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
     glEnable (GL_DEPTH_TEST);
@@ -168,6 +173,7 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)&  theWork
 
   // restore previous application state
   glClear (GL_STENCIL_BUFFER_BIT);
+  glDepthFunc (aDepthFuncPrev);
   glStencilFunc (GL_ALWAYS, 0, 0xFF);
   glDisable (GL_STENCIL_TEST);
 
diff --git a/tests/bugs/vis/bug25060 b/tests/bugs/vis/bug25060
new file mode 100644 (file)
index 0000000..30bad6e
--- /dev/null
@@ -0,0 +1,27 @@
+puts "============"
+puts "CR25060"
+puts "============"
+puts ""
+#######################################################################
+#  Capping breaks highlighting of shaded AIS_Shape with displayed edges.
+#######################################################################
+vinit View1
+box b 10 10 10
+vdisplay b
+vshowfaceboundary b 1
+vclipplane create pln1
+vclipplane set pln1 object b
+vclipplane change pln1 equation 0 1 0 -5
+vclipplane change pln1 capping on
+vsetdispmode 1
+vfit
+vmoveto 304 146
+
+set x_coord 304
+set y_coord 146
+checkcolor $x_coord $y_coord 0 1 1
+if { $stat != 1 } {
+   puts "Error : Highlighting is broken."
+}
+
+set only_screen 1