object_collection_manager: replace deprecated bgl module #104547

Closed
Oxicid wants to merge 4 commits from (deleted):oxicid-cm-bgl into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 15 additions and 25 deletions

View File

@ -6,8 +6,8 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (2, 24, 4),
"blender": (2, 80, 0),
"version": (2, 24, 5),
"blender": (2, 93, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel
"doc_url": "{BLENDER_MANUAL_URL}/addons/interface/collection_manager.html",

View File

@ -764,7 +764,7 @@ class CMSendReport(Operator):
if length > max_len:
max_len = length
return wm.invoke_popup(self, width=(30 + (max_len*5.5)))
return wm.invoke_popup(self, width=int(30 + (max_len*5.5)))
def execute(self, context):
self.report({'INFO'}, self.message)

View File

@ -5,7 +5,6 @@
import time
from math import cos, sin, pi, floor
import bpy
import bgl
import blf
import gpu
from gpu_extras.batch import batch_for_shader
@ -91,15 +90,13 @@ def draw_rounded_rect(area, shader, color, tl=5, tr=5, bl=5, br=5, outline=False
bl = round(bl * scale_factor())
br = round(br * scale_factor())
bgl.glEnable(bgl.GL_BLEND)
gpu.state.blend_set('ALPHA')
if outline:
thickness = round(2 * scale_factor())
thickness = max(thickness, 2)
bgl.glLineWidth(thickness)
bgl.glEnable(bgl.GL_LINE_SMOOTH)
bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
gpu.state.line_width_set(thickness)

line_width_set should no longer be used.

`line_width_set` should no longer be used.
draw_type = 'TRI_FAN' if not outline else 'LINE_STRIP'
@ -296,9 +293,8 @@ def draw_rounded_rect(area, shader, color, tl=5, tr=5, bl=5, br=5, outline=False
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": vertices})
batch.draw(shader)
bgl.glDisable(bgl.GL_LINE_SMOOTH)
bgl.glDisable(bgl.GL_BLEND)
gpu.state.blend_set('NONE')
def mouse_in_area(mouse_pos, area, buf = 0):
x = mouse_pos[0]
@ -844,11 +840,11 @@ def draw_callback_px(self, context):
shader.uniform_float("color", icon_color[:] + (1,))
batch = batch_for_shader(shader, 'TRI_FAN', {"pos": vertices})
bgl.glEnable(bgl.GL_BLEND)
gpu.state.blend_set('ALPHA')
batch.draw(shader)
bgl.glDisable(bgl.GL_BLEND)
gpu.state.blend_set('NONE')
# SELECTED OBJECTS
elif not set(selected_objects).isdisjoint(collection_objects):
@ -859,15 +855,12 @@ def draw_callback_px(self, context):
shader.uniform_float("color", icon_color[:] + (alpha,))
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": vertices})
bgl.glLineWidth(2 * scale_factor())
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_LINE_SMOOTH)
bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
gpu.state.line_width_set(2 * scale_factor())
gpu.state.blend_set('ALPHA')
batch.draw(shader)
bgl.glDisable(bgl.GL_LINE_SMOOTH)
bgl.glDisable(bgl.GL_BLEND)
gpu.state.blend_set('NONE')
# OBJECTS
elif collection_objects:
@ -878,11 +871,11 @@ def draw_callback_px(self, context):
shader.uniform_float("color", icon_color[:] + (alpha,))
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
bgl.glEnable(bgl.GL_BLEND)
gpu.state.blend_set('ALPHA')
batch.draw(shader)
bgl.glDisable(bgl.GL_BLEND)
gpu.state.blend_set('NONE')
# X ICON
@ -894,14 +887,11 @@ def draw_callback_px(self, context):
shader.uniform_float("color", X_icon_color[:] + (1,))
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_POLYGON_SMOOTH)
bgl.glHint(bgl.GL_POLYGON_SMOOTH_HINT, bgl.GL_NICEST)
gpu.state.blend_set('ALPHA')
batch.draw(shader)
bgl.glDisable(bgl.GL_POLYGON_SMOOTH)
bgl.glDisable(bgl.GL_BLEND)
gpu.state.blend_set('NONE')
if in_tooltip_area:
if self.draw_tooltip: