0032507: Visualization, TKOpenGl - topmost text disappears with Graphic3d_RTM_DEPTH_P...
authorsshutina <sshutina@opencascade.com>
Thu, 9 Sep 2021 14:54:13 +0000 (17:54 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 10 Sep 2021 17:24:51 +0000 (20:24 +0300)
src/OpenGl/OpenGl_DepthPeeling.hxx
src/OpenGl/OpenGl_LayerList.cxx
tests/opengl/data/transparency/oit_osdtext_bug [new file with mode: 0644]

index 7345cd9..7c34f54 100644 (file)
@@ -36,11 +36,13 @@ public:
   //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
   Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
 
-  //! Attach a texture image
+  //! Attach a texture image.
+  //! Resets the active FBO to 0.
   Standard_EXPORT void AttachDepthTexture (const Handle(OpenGl_Context)& theCtx,
                                            const Handle(OpenGl_Texture)& theDepthStencilTexture);
 
-  //! Detach a texture image
+  //! Detach a texture image.
+  //! Resets the active FBO to 0.
   Standard_EXPORT void DetachDepthTexture (const Handle(OpenGl_Context)& theCtx);
 
   //! Returns additional buffers for ping-pong
index 53d616f..d12e38e 100644 (file)
@@ -1219,6 +1219,13 @@ void OpenGl_LayerList::renderTransparent (const Handle(OpenGl_Workspace)&   theW
         }
       }
       aView->DepthPeelingFbos()->DetachDepthTexture (aCtx);
+
+      // Bind the framebuffer for reading depth and writing final color
+      // after DetachDepthTexture() because after the function it's unbinded.
+      if (theReadDrawFbo)
+      {
+        theReadDrawFbo->BindBuffer (aCtx);
+      }
       break;
     }
   }
diff --git a/tests/opengl/data/transparency/oit_osdtext_bug b/tests/opengl/data/transparency/oit_osdtext_bug
new file mode 100644 (file)
index 0000000..ef688e3
--- /dev/null
@@ -0,0 +1,26 @@
+puts "========"
+puts "0032507: Visualization, TKOpenGl - topmost text disappears with Graphic3d_RTM_DEPTH_PEELING_OIT enabled"
+puts "========"
+
+pload MODELING VISUALIZATION
+
+vclear
+vinit View1
+
+box b 1 2 3
+vdisplay b -dispMode 1
+vaspects b -transparency 0.5
+vfit
+
+vlight   headlight -display
+vdisplay headlight -2d bottomright 120 50
+vlight   amblight  -display
+vdisplay amblight  -2d bottomright  50 50
+
+vrenderparams -perfCounters triangles
+
+vdump $imagedir/${casename}_1.png
+
+vrenderparams -oit peel
+
+vdump $imagedir/${casename}_2.png