diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2019-05-21 14:53:17 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2019-05-21 16:36:05 +0300 |
commit | 903e5d39729023883e40641b0fed605a686e72f3 (patch) | |
tree | 53679e4de349af7797a79c1176811595f67be0da /release/scripts/templates_py | |
parent | 91ce3087aa7f763d202d913a3d77e571662654c9 (diff) |
python templates: update operator_modal_draw to 2.8
part of T56351
Reviewers: JacquesLucke
Differential Revision: https://developer.blender.org/D4912
Diffstat (limited to 'release/scripts/templates_py')
-rw-r--r-- | release/scripts/templates_py/operator_modal_draw.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/release/scripts/templates_py/operator_modal_draw.py b/release/scripts/templates_py/operator_modal_draw.py index 6f75d6c632e..5dc72c36a8f 100644 --- a/release/scripts/templates_py/operator_modal_draw.py +++ b/release/scripts/templates_py/operator_modal_draw.py @@ -1,7 +1,8 @@ import bpy import bgl import blf - +import gpu +from gpu_extras.batch import batch_for_shader def draw_callback_px(self, context): print("mouse points", len(self.mouse_path)) @@ -14,20 +15,17 @@ def draw_callback_px(self, context): blf.draw(font_id, "Hello Word " + str(len(self.mouse_path))) # 50% alpha, 2 pixel width line + shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') bgl.glEnable(bgl.GL_BLEND) - bgl.glColor4f(0.0, 0.0, 0.0, 0.5) bgl.glLineWidth(2) - - bgl.glBegin(bgl.GL_LINE_STRIP) - for x, y in self.mouse_path: - bgl.glVertex2i(x, y) - - bgl.glEnd() + 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) - bgl.glColor4f(0.0, 0.0, 0.0, 1.0) class ModalDrawOperator(bpy.types.Operator): |