From 25192cb491e5ddae8ae8faf34d455defc558aac4 Mon Sep 17 00:00:00 2001 From: Cody Winchester Date: Wed, 15 Nov 2023 00:22:59 -0600 Subject: [PATCH] Replace BGL with GPU module for 4.0 Completely removes BGL module and replaces with the new GPU module so it works with 4.0 --- __init__.py | 4 +-- classes.py | 13 +++++---- cui_classes/cui_bezier_items.py | 43 +++++++++++++++--------------- cui_classes/cui_containers.py | 19 +++++-------- cui_classes/cui_functions.py | 17 ++++++++---- cui_classes/cui_items.py | 47 ++++++++++++++++++--------------- cui_classes/cui_shapes.py | 31 ++++++++++++---------- cui_classes/cui_window.py | 35 +++++++++++++++++++----- functions_drawing.py | 29 ++++++++++---------- operators_modal.py | 11 ++++++-- 10 files changed, 145 insertions(+), 104 deletions(-) diff --git a/__init__.py b/__init__.py index 159d0de..1332261 100644 --- a/__init__.py +++ b/__init__.py @@ -8,8 +8,8 @@ bl_info = { "name": "Abnormal", "author": "Cody Winchester (codywinch)", - "version": (1, 1, 3), - "blender": (3, 60, 0), + "version": (1, 1, 4), + "blender": (4, 0, 0), "location": "3D View > N Panel/Header > BNPR Abnormal Tab", "description": "BNPR Normal Editing Tools", "warning": "", diff --git a/classes.py b/classes.py index 9c7372c..710cf26 100644 --- a/classes.py +++ b/classes.py @@ -1,5 +1,4 @@ import bpy -import bgl import gpu import numpy as np from gpu_extras.batch import batch_for_shader @@ -78,7 +77,11 @@ def __init__(self, mat, alt_shader=False): return def create_alt_shader(self): - self.shader = gpu.shader.from_builtin('3D_FLAT_COLOR') + if bpy.app.version[0] >= 4: + shader_3d_str = 'FLAT_COLOR' + else: + shader_3d_str = '3D_FLAT_COLOR' + self.shader = gpu.shader.from_builtin(shader_3d_str) return def create_shader(self): @@ -395,18 +398,18 @@ def draw(self): self.shader.bind() self.batch_tri.draw(self.shader) - bgl.glPointSize(5*self.size) + gpu.state.point_size_set(5*self.size) # Static Non Sel Points self.shader.bind() self.batch_po.draw(self.shader) # Static Sel Points - bgl.glPointSize(8*self.size) + gpu.state.point_size_set(8*self.size) self.shader.bind() self.batch_po_sel.draw(self.shader) # Static Act Points - bgl.glPointSize(11*self.size) + gpu.state.point_size_set(11*self.size) self.shader.bind() self.batch_po_act.draw(self.shader) diff --git a/cui_classes/cui_bezier_items.py b/cui_classes/cui_bezier_items.py index 1cb5e0b..2654427 100644 --- a/cui_classes/cui_bezier_items.py +++ b/cui_classes/cui_bezier_items.py @@ -1,4 +1,3 @@ -import bgl import gpu from gpu_extras.batch import batch_for_shader from .cui_functions import * @@ -126,19 +125,20 @@ def draw(self, color_override=None, click_down=False): if self.visible: super().draw() - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') self.shader.bind() - bgl.glLineWidth(self.line_thickness) + + gpu.state.line_width_set(self.line_thickness) self.shader.uniform_float("color", self.color_axis_lines_render) self.batch_lines.draw(self.shader) self.shader.bind() - bgl.glLineWidth(self.inbtwn_thickness) + gpu.state.line_width_set(self.inbtwn_thickness) self.shader.uniform_float("color", self.color_inbtwn_lines_render) self.batch_inbtwn_lines.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return # @@ -747,13 +747,10 @@ def click_down_move(self, mouse_co, shift, position, arguments=None): def draw(self): # Get a currently in use scissor to reenable after the new scissor - cur_scissor = None - if bgl.glIsEnabled(bgl.GL_SCISSOR_TEST) == 1: - cur_scissor = bgl.Buffer(bgl.GL_INT, 4) - bgl.glGetIntegerv(bgl.GL_SCISSOR_BOX, cur_scissor) + cur_scissor = gpu.state.scissor_get() - bgl.glEnable(bgl.GL_SCISSOR_TEST) - bgl.glScissor( + gpu.state.scissor_test_set(True) + gpu.state.scissor_set( int(round(self.final_pos[0])), int(round(self.final_pos[1]-self.scale_height)), int(round(self.scale_width)), @@ -768,12 +765,12 @@ def draw(self): # Disable scissor as there is no previous scissor to continue with if cur_scissor is None: - bgl.glDisable(bgl.GL_SCISSOR_TEST) + gpu.state.scissor_test_set(False) # Reenable previous scissor else: - bgl.glEnable(bgl.GL_SCISSOR_TEST) - bgl.glScissor( + gpu.state.scissor_test_set(True) + gpu.state.scissor_set( cur_scissor[0], cur_scissor[1], cur_scissor[2], cur_scissor[3]) return @@ -1315,7 +1312,11 @@ class CUIBaseSpline: # Basic spline class to be used for shape splines and fcurves # def __init__(self): - self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') + if bpy.app.version[0] >= 4: + shader_2d_str = 'UNIFORM_COLOR' + else: + shader_2d_str = '2D_UNIFORM_COLOR' + self.shader = gpu.shader.from_builtin(shader_2d_str) self.scale = 1.0 @@ -1440,14 +1441,14 @@ def update_color_render(self): return def draw(self): - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') - bgl.glLineWidth(self.spline_thickness) + gpu.state.line_width_set(self.spline_thickness) self.shader.bind() self.shader.uniform_float("color", self.color_render) self.batch.draw(self.shader) - bgl.glLineWidth(self.handle_thickness) + gpu.state.line_width_set(self.handle_thickness) self.shader.bind() self.shader.uniform_float("color", self.color_handles_render) self.batch_handles.draw(self.shader) @@ -1460,7 +1461,7 @@ def draw(self): self.shader.uniform_float("color", self.color_pos_sel_render) self.batch_pos_sel.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return @@ -1722,11 +1723,11 @@ def update_color_render(self): return def draw(self): - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') self.shader.bind() self.shader.uniform_float("color", self.color_area_render) self.batch_area.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') super().draw() diff --git a/cui_classes/cui_containers.py b/cui_classes/cui_containers.py index 4b55e72..f0d8f55 100644 --- a/cui_classes/cui_containers.py +++ b/cui_classes/cui_containers.py @@ -1,4 +1,3 @@ -import bgl from .cui_shapes import * from .cui_bezier_items import * from .cui_items import * @@ -239,10 +238,7 @@ def draw(self): # Some test code is there for multi scissor boxes if I ever intend to try again if self.scrolling and (self.type == 'PANEL' or 'POPUP' in self.type): # Get a currently in use scissor to reenable after the new scissor - cur_scissor = None - if bgl.glIsEnabled(bgl.GL_SCISSOR_TEST) == 1: - cur_scissor = bgl.Buffer(bgl.GL_INT, 4) - bgl.glGetIntegerv(bgl.GL_SCISSOR_BOX, cur_scissor) + cur_scissor = gpu.state.scissor_get() # clip_pos = pos.copy() # clip_pos[0] += self.horizontal_margin @@ -252,11 +248,10 @@ def draw(self): # if pos[1]+self.scroll_offset > position[1]: # offset = pos[1]+self.scroll_offset-position[1] - bgl.glEnable(bgl.GL_SCISSOR_TEST) - bgl.glScissor( + gpu.state.scissor_test_set(True) + gpu.state.scissor_set( int(round(self.final_pos[0]+self.horizontal_margin)), - int(round( - self.final_pos[1]-self.scale_height+self.vertical_margin)), + int(round(self.final_pos[1]-self.scale_height+self.vertical_margin)), int(round((self.scale_width-self.horizontal_margin*2))), int(round((self.scale_height-self.vertical_margin*2-offset))) ) @@ -268,12 +263,12 @@ def draw(self): if self.scrolling and (self.type == 'PANEL' or 'POPUP' in self.type): # Disable scissor as there is no previous scissor to continue with if cur_scissor is None: - bgl.glDisable(bgl.GL_SCISSOR_TEST) + gpu.state.scissor_test_set(False) # Reenable previous scissor else: - bgl.glEnable(bgl.GL_SCISSOR_TEST) - bgl.glScissor( + gpu.state.scissor_test_set(True) + gpu.state.scissor_set( cur_scissor[0], cur_scissor[1], cur_scissor[2], cur_scissor[3]) return diff --git a/cui_classes/cui_functions.py b/cui_classes/cui_functions.py index c55f764..e6b7a94 100644 --- a/cui_classes/cui_functions.py +++ b/cui_classes/cui_functions.py @@ -5,8 +5,10 @@ def scale_font_size(text, font_size, font_id, scale): - - blf.size(font_id, font_size, 72) + if bpy.app.version[0] >= 4: + blf.size(font_id, font_size) + else: + blf.size(font_id, font_size, 72) blf.position(font_id, 0, 0, 0) size_w = blf.dimensions(font_id, text) @@ -23,14 +25,19 @@ def scale_font_size(text, font_size, font_id, scale): # A size is found that is just over the target width of the scaled size while cur_width <= targ_width: cur_size += 1 - - blf.size(font_id, cur_size, 72) + if bpy.app.version[0] >= 4: + blf.size(font_id, cur_size) + else: + blf.size(font_id, cur_size, 72) cur_width, cur_height = blf.dimensions( font_id, text) # When the font size that is just larger is found set the current font size to 1 below that cur_size -= 1 - blf.size(font_id, cur_size, 72) + if bpy.app.version[0] >= 4: + blf.size(font_id, cur_size) + else: + blf.size(font_id, cur_size, 72) size_w = blf.dimensions(font_id, text) return cur_size diff --git a/cui_classes/cui_items.py b/cui_classes/cui_items.py index 37081ef..dffb05c 100644 --- a/cui_classes/cui_items.py +++ b/cui_classes/cui_items.py @@ -1,6 +1,5 @@ import bpy import blf -import bgl import gpu from gpu_extras.batch import batch_for_shader from .cui_functions import * @@ -224,7 +223,11 @@ def __init__(self, height, text): self.text_auto_y = True self.text_margin = 2 - self.shader_img = gpu.shader.from_builtin('2D_IMAGE') + if bpy.app.version[0] >= 4: + shader_img_str = 'IMAGE' + else: + shader_img_str = '2D_IMAGE' + self.shader_img = gpu.shader.from_builtin(shader_img_str) self.icon_pos = np.array([0.0, 0.0, 0.0, 0.0], dtype=np.float32) self.icon_pos_offset = np.array([0.0, 0.0], dtype=np.float32) @@ -275,8 +278,10 @@ def create_shape_data(self, value='', text=None): if self.text_render != '': cur_size = scale_font_size( self.text_render, self.font_size, self.font_id, self.scale) - - blf.size(self.font_id, cur_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.font_id, cur_size) + else: + blf.size(self.font_id, cur_size, 72) size_w = blf.dimensions(self.font_id, self.text_render) size_h = blf.dimensions(self.font_id, 'T') @@ -426,18 +431,20 @@ def icon_draw(self): if icon_img.gl_load(): raise Exception() - bgl.glEnable(bgl.GL_BLEND) - bgl.glActiveTexture(bgl.GL_TEXTURE0) - bgl.glBindTexture(bgl.GL_TEXTURE_2D, icon_img.bindcode) + gpu.state.blend_set('ALPHA') + texture = gpu.texture.from_image(icon_img) self.shader_img.bind() - self.shader_img.uniform_int("image", 0) + self.shader_img.uniform_sampler("image", texture) self.batch_icon.draw(self.shader_img) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return def text_draw(self): if self.visible and self.text_render != '': - blf.size(self.font_id, self.scale_font_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.font_id, self.scale_font_size) + else: + blf.size(self.font_id, self.scale_font_size, 72) blf.position(self.font_id, self.text_pos[0], self.text_pos[1], 0) blf.color( self.font_id, self.color_font_render[0], self.color_font_render[1], self.color_font_render[2], self.color_font_render[3]) @@ -600,12 +607,12 @@ def draw(self, color_override=None, click_down=False): if self.bool_val and self.draw_check: - bgl.glEnable(bgl.GL_BLEND) - bgl.glLineWidth(self.bool_thickness) + gpu.state.blend_set('ALPHA') + gpu.state.line_width_set(self.bool_thickness) self.shader.bind() self.shader.uniform_float("color", self.color_check_render) self.batch_check.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return @@ -1734,11 +1741,9 @@ def __init__(self, mat, size, scale): def draw(self): if self.visible: - # bgl.glDepthRange(0, 0.01) for i in range(len(self.gizmos)): if self.gizmos[i*-1-1].active: self.gizmos[i*-1-1].draw() - # bgl.glDepthRange(0, 1.0) return def create_shape_data(self, matrix): @@ -1839,7 +1844,11 @@ def __str__(self): class CUIGizmo: def __init__(self, size, scale, axis, giz_type, color): - self.shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + if bpy.app.version[0] >= 4: + shader_3d_str = 'UNIFORM_COLOR' + else: + shader_3d_str = '3D_UNIFORM_COLOR' + self.shader = gpu.shader.from_builtin(shader_3d_str) self.axis = axis self.type = giz_type @@ -1863,7 +1872,6 @@ def __init__(self, size, scale, axis, giz_type, color): def draw(self): if self.active: - # bgl.glDepthRange(0, 0.01) self.shader.bind() if self.hover and self.in_use == False: @@ -1872,8 +1880,6 @@ def draw(self): self.shader.uniform_float("color", self.color) self.batch.draw(self.shader) - # bgl.glDepthRange(0, 1.0) - return # @@ -1961,7 +1967,6 @@ def __init__(self, size, scale, axis, giz_type, color, thickness=6): def draw(self): if self.active: - # bgl.glDepthRange(0, 0.01) if self.in_use: self.shader.bind() @@ -1980,8 +1985,6 @@ def draw(self): self.shader.uniform_float("color", self.color) self.batch.draw(self.shader) - # bgl.glDepthRange(0, 1.0) - return # diff --git a/cui_classes/cui_shapes.py b/cui_classes/cui_shapes.py index 8e9ae77..77ca734 100644 --- a/cui_classes/cui_shapes.py +++ b/cui_classes/cui_shapes.py @@ -1,4 +1,3 @@ -import bgl import gpu from gpu_extras.batch import batch_for_shader from .cui_functions import * @@ -14,7 +13,11 @@ class CUIBaseWidgetData: # Creates base data used by all widgets # def __init__(self): - self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') + if bpy.app.version[0] >= 4: + shader_2d_str = 'UNIFORM_COLOR' + else: + shader_2d_str = '2D_UNIFORM_COLOR' + self.shader = gpu.shader.from_builtin(shader_2d_str) self.scale = 1.0 @@ -118,19 +121,19 @@ def update_color_render(self): def draw(self): if self.visible: - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') self.shader.bind() self.shader.uniform_float("color", self.color_render) self.batch_box.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') if self.use_outline: - bgl.glEnable(bgl.GL_BLEND) - bgl.glLineWidth(self.scale_outline_thickness) + gpu.state.blend_set('ALPHA') + gpu.state.line_width_set(self.scale_outline_thickness) self.shader.bind() self.shader.uniform_float("color", self.color_outline_render) self.batch_box_lines.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return # @@ -276,7 +279,7 @@ def update_color_render(self): def draw(self, color_override=None): if self.visible: if self.draw_box: - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') self.shader.bind() if color_override: @@ -289,15 +292,15 @@ def draw(self, color_override=None): self.shader.uniform_float("color", self.color_render) self.batch_box.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') if self.use_outline: - bgl.glEnable(bgl.GL_BLEND) - bgl.glLineWidth(self.scale_outline_thickness) + gpu.state.blend_set('ALPHA') + gpu.state.line_width_set(self.scale_outline_thickness) self.shader.bind() self.shader.uniform_float("color", self.color_outline_render) self.batch_box_lines.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return # @@ -485,7 +488,7 @@ def update_color_render(self): def draw(self, color_override=None): if self.visible: - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') self.shader.bind() if color_override: @@ -494,7 +497,7 @@ def draw(self, color_override=None): self.shader.uniform_float("color", self.color_render) self.batch.draw(self.shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') return # diff --git a/cui_classes/cui_window.py b/cui_classes/cui_window.py index e87b14b..7f8395f 100644 --- a/cui_classes/cui_window.py +++ b/cui_classes/cui_window.py @@ -113,7 +113,10 @@ def status_draw(self): self.status_pos[0], self.status_pos[1], 0) blf.color( self.status_font, self.color_status_render[0], self.color_status_render[1], self.color_status_render[2], self.color_status_render[3]) - blf.size(self.status_font, self.status_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.status_font, self.status_size) + else: + blf.size(self.status_font, self.status_size, 72) blf.draw(self.status_font, self.status_text) return @@ -124,7 +127,10 @@ def key_draw(self): self.key_pos[0], self.key_pos[1], 0) blf.color( self.key_font, self.color_key_render[0], self.color_key_render[1], self.color_key_render[2], self.color_key_render[3]) - blf.size(self.key_font, self.key_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.key_font, self.key_size) + else: + blf.size(self.key_font, self.key_size, 72) blf.draw(self.key_font, self.key_text) return @@ -328,8 +334,13 @@ def tooltip_show(self, mouse_co): font_size=self.tooltip_box.font_size) label.set_text_alignment('LEFT') + if bpy.app.version[0] >= 4: + blf.size(self.tooltip_box.font_id, + self.tooltip_box.font_size) + else: blf.size(self.tooltip_box.font_id, self.tooltip_box.font_size, 72) + size_w = blf.dimensions(self.tooltip_box.font_id, line) size_h = blf.dimensions(self.tooltip_box.font_id, 'T') @@ -883,7 +894,10 @@ def set_status(self, text): return def set_status_size(self, size): - blf.size(self.status_font, self.status_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.status_font, self.status_size) + else: + blf.size(self.status_font, self.status_size, 72) size = blf.dimensions(self.status_font, self.status_text) self.status_size = size * self.scale @@ -900,7 +914,10 @@ def set_status_alignment(self, alignment): return def place_status_text(self): - blf.size(self.status_font, self.status_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.status_font, self.status_size) + else: + blf.size(self.status_font, self.status_size, 72) size = blf.dimensions(self.status_font, self.status_text) if 'T' in self.status_alignment: @@ -938,7 +955,10 @@ def set_key(self, text): return def set_key_size(self, size): - blf.size(self.key_font, self.key_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.key_font, self.key_size) + else: + blf.size(self.key_font, self.key_size, 72) size = blf.dimensions(self.key_font, self.key_text) self.key_size = size * self.scale @@ -955,7 +975,10 @@ def set_key_alignment(self, alignment): return def place_key_text(self): - blf.size(self.key_font, self.key_size, 72) + if bpy.app.version[0] >= 4: + blf.size(self.key_font, self.key_size) + else: + blf.size(self.key_font, self.key_size, 72) size = blf.dimensions(self.key_font, self.key_text) if 'T' in self.key_alignment: diff --git a/functions_drawing.py b/functions_drawing.py index 7b77e89..aaccc4c 100644 --- a/functions_drawing.py +++ b/functions_drawing.py @@ -1,5 +1,5 @@ import bpy -import bgl +import gpu import traceback from mathutils import Vector from gpu_extras.batch import batch_for_shader @@ -32,17 +32,16 @@ def draw_callback_3d(modal, context): clear_draw = True if context.area == modal._draw_area: - - bgl.glEnable(bgl.GL_BLEND) - bgl.glEnable(bgl.GL_VERTEX_PROGRAM_POINT_SIZE) + gpu.state.blend_set('ALPHA') + gpu.state.program_point_size_set(True) if modal._x_ray_mode == False: - bgl.glEnable(bgl.GL_DEPTH_TEST) + gpu.state.depth_test_set("LESS_EQUAL") modal._container.draw() if len(modal.translate_draw_line) > 0: - bgl.glEnable(bgl.GL_DEPTH_TEST) - bgl.glLineWidth(2) + gpu.state.depth_test_set("LESS_EQUAL") + gpu.state.line_width_set(2) modal.shader_3d.bind() if modal.translate_axis == 0: modal.shader_3d.uniform_float("color", (1.0, 0.0, 0.0, 1.0)) @@ -51,16 +50,16 @@ def draw_callback_3d(modal, context): if modal.translate_axis == 2: modal.shader_3d.uniform_float("color", (0.0, 0.0, 1.0, 1.0)) modal.batch_translate_line.draw(modal.shader_3d) - bgl.glDisable(bgl.GL_DEPTH_TEST) + gpu.state.depth_test_set("NONE") if modal._x_ray_mode == False: - bgl.glDisable(bgl.GL_DEPTH_TEST) + gpu.state.depth_test_set("NONE") if modal._use_gizmo: modal._window.gizmo_draw() - bgl.glDisable(bgl.GL_BLEND) - bgl.glDisable(bgl.GL_VERTEX_PROGRAM_POINT_SIZE) + gpu.state.blend_set('NONE') + gpu.state.program_point_size_set(False) except Exception: print() @@ -96,22 +95,22 @@ def draw_callback_2d(modal, context): clear_draw = True if context.area == modal._draw_area: - bgl.glLineWidth(2) + gpu.state.line_width_set(2) modal.shader_2d.bind() modal.shader_2d.uniform_float("color", (0.05, 0.05, 0.05, 1)) modal.batch_rotate_screen_lines.draw(modal.shader_2d) - bgl.glLineWidth(1) + gpu.state.line_width_set(1) modal.shader_2d.bind() modal.shader_2d.uniform_float("color", (1.0, 1.0, 1.0, 1)) modal.batch_boxsel_screen_lines.draw(modal.shader_2d) - bgl.glLineWidth(1) + gpu.state.line_width_set(1) modal.shader_2d.bind() modal.shader_2d.uniform_float("color", (1.0, 1.0, 1.0, 1)) modal.batch_circlesel_screen_lines.draw(modal.shader_2d) - bgl.glLineWidth(1) + gpu.state.line_width_set(1) modal.shader_2d.bind() modal.shader_2d.uniform_float("color", (1.0, 1.0, 1.0, 1)) modal.batch_lassosel_screen_lines.draw(modal.shader_2d) diff --git a/operators_modal.py b/operators_modal.py index c76e32b..874f6d4 100644 --- a/operators_modal.py +++ b/operators_modal.py @@ -221,9 +221,16 @@ def invoke(self, context, event): self._object.data.use_auto_smooth = True self._object.data.auto_smooth_angle = 180 + if bpy.app.version[0] >= 4: + shader_2d_str = 'UNIFORM_COLOR' + shader_3d_str = 'UNIFORM_COLOR' + else: + shader_2d_str = '2D_UNIFORM_COLOR' + shader_3d_str = '3D_UNIFORM_COLOR' + # INITIALIZE BATCHES AND SHADERS - self.shader_2d = gpu.shader.from_builtin('2D_UNIFORM_COLOR') - self.shader_3d = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + self.shader_2d = gpu.shader.from_builtin(shader_2d_str) + self.shader_3d = gpu.shader.from_builtin(shader_3d_str) self._container = ABNContainer( self._object.matrix_world.normalized(), alt_shader=self._behavior_prefs.alt_drawing)