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

Since 216d78687d 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
This commit is contained in:
Campbell Barton 2021-01-28 21:16:17 +11:00
parent 51c8d53a7d
commit 8948f73784
Notes: blender-bot 2023-02-14 09:02:41 +01:00
Referenced by issue #81334, viewport drawing with gpu module
1 changed files with 14 additions and 0 deletions

View File

@ -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;
}