From 294e899bf73cf461eee98c89a8583503cdcf58f5 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 21 Jul 2022 11:03:07 -0300 Subject: Grease Pencil Tools: replace deprecated bgl module Part of T80730 --- greasepencil_tools/__init__.py | 4 ++-- greasepencil_tools/rotate_canvas.py | 9 ++++----- greasepencil_tools/timeline_scrub.py | 13 ++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'greasepencil_tools') diff --git a/greasepencil_tools/__init__.py b/greasepencil_tools/__init__.py index 980493ed..c75d0442 100644 --- a/greasepencil_tools/__init__.py +++ b/greasepencil_tools/__init__.py @@ -4,8 +4,8 @@ bl_info = { "name": "Grease Pencil Tools", "description": "Extra tools for Grease Pencil", "author": "Samuel Bernou, Antonio Vazquez, Daniel Martinez Lara, Matias Mendiola", -"version": (1, 6, 0), -"blender": (2, 91, 0), +"version": (1, 6, 1), +"blender": (3, 0, 0), "location": "Sidebar > Grease Pencil > Grease Pencil Tools", "warning": "", "doc_url": "{BLENDER_MANUAL_URL}/addons/object/greasepencil_tools.html", diff --git a/greasepencil_tools/rotate_canvas.py b/greasepencil_tools/rotate_canvas.py index a733eb2d..c2482fbd 100644 --- a/greasepencil_tools/rotate_canvas.py +++ b/greasepencil_tools/rotate_canvas.py @@ -10,7 +10,6 @@ from bpy.props import BoolProperty, EnumProperty from time import time ## draw utils import gpu -import bgl import blf from gpu_extras.batch import batch_for_shader from gpu_extras.presets import draw_circle_2d @@ -31,8 +30,8 @@ def draw_callback_px(self, context): if context.area != self.current_area: return 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) # init batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": [self.center, self.initial_pos]})#self.vector_initial @@ -55,8 +54,8 @@ def draw_callback_px(self, context): # 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') ## text font_id = 0 diff --git a/greasepencil_tools/timeline_scrub.py b/greasepencil_tools/timeline_scrub.py index 6a1913ae..1f6c2a41 100644 --- a/greasepencil_tools/timeline_scrub.py +++ b/greasepencil_tools/timeline_scrub.py @@ -8,7 +8,6 @@ import numpy as np from time import time import bpy import gpu -import bgl import blf from gpu_extras.batch import batch_for_shader @@ -39,8 +38,8 @@ def draw_callback_px(self, context): font_id = 0 shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') # initiate shader - bgl.glEnable(bgl.GL_BLEND) - bgl.glLineWidth(1) + gpu.state.blend_set('ALPHA') + gpu.state.line_width_set(1.0) # Draw HUD if self.use_hud_time_line: @@ -51,18 +50,18 @@ def draw_callback_px(self, context): # Display keyframes if self.use_hud_keyframes: if self.keyframe_aspect == 'LINE': - bgl.glLineWidth(3) + gpu.state.line_width_set(3.0) shader.bind() shader.uniform_float("color", self.color_timeline) self.batch_keyframes.draw(shader) else: - bgl.glLineWidth(1) + gpu.state.line_width_set(1.0) shader.bind() shader.uniform_float("color", self.color_timeline) self.batch_keyframes.draw(shader) # Show current frame line - bgl.glLineWidth(1) + gpu.state.line_width_set(1.0) if self.use_hud_playhead: playhead = [(self.cursor_x, self.my + self.playhead_size/2), (self.cursor_x, self.my - self.playhead_size/2)] @@ -72,7 +71,7 @@ def draw_callback_px(self, context): batch.draw(shader) # restore opengl defaults - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') # Display current frame text blf.color(font_id, *self.color_text) -- cgit v1.2.3