Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <mano-wii>2021-05-01 17:59:54 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-05-01 18:12:58 +0300
commit6fff2427d623119a373e7991a319a75d65ed387e (patch)
treeedaed5b12eb0986d53a08f84b54a2945f484b6f8 /release/scripts/templates_py
parent6111ec8bd3296320c9d7ac15a40f25b15b997754 (diff)
Python GPU: Replace a few calls of the bgl module with gpu
Concludes these files: [x]bpy_types.py [x]operator_modal_draw.py Reviewed By: fclem Differential Revision: https://developer.blender.org/D11129
Diffstat (limited to 'release/scripts/templates_py')
-rw-r--r--release/scripts/templates_py/operator_modal_draw.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/release/scripts/templates_py/operator_modal_draw.py b/release/scripts/templates_py/operator_modal_draw.py
index 1e185ecfe2b..16c6f6dbe22 100644
--- a/release/scripts/templates_py/operator_modal_draw.py
+++ b/release/scripts/templates_py/operator_modal_draw.py
@@ -1,5 +1,4 @@
import bpy
-import bgl
import blf
import gpu
from gpu_extras.batch import batch_for_shader
@@ -17,16 +16,16 @@ def draw_callback_px(self, context):
# 50% alpha, 2 pixel width line
shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glLineWidth(2)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.line_width_set(2.0)
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": self.mouse_path})
shader.bind()
shader.uniform_float("color", (0.0, 0.0, 0.0, 0.5))
batch.draw(shader)
# restore opengl defaults
- bgl.glLineWidth(1)
- bgl.glDisable(bgl.GL_BLEND)
+ gpu.state.line_width_set(1.0)
+ gpu.state.blend_set('NONE')
class ModalDrawOperator(bpy.types.Operator):