0024819: TKOpenGl - extend the ray-tracing core by visualization of lines, text and...
[occt.git] / src / Visual3d / Visual3d_View.cxx
index 1834df7..f33d6ea 100644 (file)
@@ -1051,35 +1051,43 @@ void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
     return;
   }
 
-  if (MyGraphicDriver->IsDeviceLost())
-  {
-    MyViewManager->RecomputeStructures();
-    MyViewManager->RecomputeStructures (myImmediateStructures);
-    MyGraphicDriver->ResetDeviceLostFlag();
-  }
+  Aspect_CLayer2d anOverCLayer, anUnderCLayer;
+  anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
+  if (!theOverLayer .IsNull()) anOverCLayer  = theOverLayer ->CLayer();
+  if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
 
-  // set up Z buffer state before redrawing
-  if (MyViewManager->ZBufferAuto())
+  for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
   {
-    const Standard_Boolean hasFacet   = ContainsFacet();
-    const Standard_Boolean hasZBuffer = ZBufferIsActivated();
-    // if the view contains facets and if ZBuffer is not active
-    if (hasFacet && !hasZBuffer)
+    if (MyGraphicDriver->IsDeviceLost())
     {
-      SetZBufferActivity (1);
+      MyViewManager->RecomputeStructures();
+      MyViewManager->RecomputeStructures (myImmediateStructures);
+      MyGraphicDriver->ResetDeviceLostFlag();
     }
-    // if the view contains only facets and if ZBuffer is active
-    if (!hasFacet && hasZBuffer)
+
+    // set up Z buffer state before redrawing
+    if (MyViewManager->ZBufferAuto())
     {
-      SetZBufferActivity (0);
+      const Standard_Boolean hasFacet   = ContainsFacet();
+      const Standard_Boolean hasZBuffer = ZBufferIsActivated();
+      // if the view contains facets and if ZBuffer is not active
+      if (hasFacet && !hasZBuffer)
+      {
+        SetZBufferActivity (1);
+      }
+      // if the view contains only facets and if ZBuffer is active
+      if (!hasFacet && hasZBuffer)
+      {
+        SetZBufferActivity (0);
+      }
     }
-  }
 
-  Aspect_CLayer2d anOverCLayer, anUnderCLayer;
-  anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
-  if (!theOverLayer .IsNull()) anOverCLayer  = theOverLayer ->CLayer();
-  if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
-  MyGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight);
+    MyGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight);
+    if (!MyGraphicDriver->IsDeviceLost())
+    {
+      return;
+    }
+  }
 }
 
 void Visual3d_View::RedrawImmediate()