0031704: Visualization - add an interactive object AIS_LightSource representing a...
[occt.git] / src / OpenGl / OpenGl_Structure.cxx
index ac9e12d..1b4af03 100644 (file)
@@ -441,6 +441,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
 #endif
 
   bool anOldCastShadows = false;
+#ifdef GL_DEPTH_CLAMP
+  bool toRestoreDepthClamp = false;
+#endif
   if (!myTrsfPers.IsNull())
   {
     // temporarily disable shadows on non-3d objects
@@ -463,6 +466,15 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
       }
     }
   #endif
+
+  #ifdef GL_DEPTH_CLAMP
+    if (myTrsfPers->Mode() == Graphic3d_TMF_CameraPers
+     && aCtx->arbDepthClamp)
+    {
+      toRestoreDepthClamp = true;
+      aCtx->core11fwd->glEnable (GL_DEPTH_CLAMP);
+    }
+  #endif
   }
 
   // Take into account transform persistence
@@ -613,6 +625,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
   {
     aCtx->WorldViewState.Pop();
     aCtx->ShaderManager()->SetCastShadows (anOldCastShadows);
+  #ifdef GL_DEPTH_CLAMP
+    if (toRestoreDepthClamp) { aCtx->core11fwd->glDisable (GL_DEPTH_CLAMP); }
+  #endif
   }
 
   // Restore named status