[Bf-blender-cvs] [8948f73784c] blender-v2.92-release: Fix T81334: Python view-port drawing depth-test regression

Campbell Barton noreply at git.blender.org
Thu Jan 28 11:55:06 CET 2021


Commit: 8948f73784cb818689ba38aa9ae5008eb3c8290b
Author: Campbell Barton
Date:   Thu Jan 28 21:16:17 2021 +1100
Branches: blender-v2.92-release
https://developer.blender.org/rB8948f73784cb818689ba38aa9ae5008eb3c8290b

Fix T81334: Python view-port drawing depth-test regression

Since 216d78687d2b9468b05fb598d1cef0b8424a40d2 the depth function
(glDepthFunc) was left in an undefined state for drawing callbacks that
use the `bgl` module.

This meant enabling depth-test from Python's bgl module also needed
to set the depth function (which previously wasn't necessary).

Set the depth function as part of GPU_bgl_start

===================================================================

M	source/blender/gpu/intern/gpu_state.cc

===================================================================

diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index 407a8dd6e2b..e158601a25c 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -339,6 +339,20 @@ void GPU_bgl_start()
     /* Expected by many addons (see T80169, T81289).
      * This will reset the blend function. */
     GPU_blend(GPU_BLEND_NONE);
+
+    /* Equivalent of setting the depth func `glDepthFunc(GL_LEQUAL)`
+     * Needed since Python scripts may enable depth test.
+     * Without this block the depth test function is undefined. */
+    {
+      eGPUDepthTest depth_test_real = GPU_depth_test_get();
+      eGPUDepthTest depth_test_temp = GPU_DEPTH_LESS_EQUAL;
+      if (depth_test_real != depth_test_temp) {
+        GPU_depth_test(depth_test_temp);
+        state_manager.apply_state();
+        GPU_depth_test(depth_test_real);
+      }
+    }
+
     state_manager.apply_state();
     state_manager.use_bgl = true;
   }



More information about the Bf-blender-cvs mailing list