[Bf-extensions-cvs] [c8109966] master: Scatter Objects: replace deprecated bgl module

Germano Cavalcante noreply at git.blender.org
Thu Jul 28 17:34:44 CEST 2022


Commit: c8109966ce74ba9516d81f1bc98a64d00eeb0b67
Author: Germano Cavalcante
Date:   Thu Jul 28 12:12:54 2022 -0300
Branches: master
https://developer.blender.org/rBAc8109966ce74ba9516d81f1bc98a64d00eeb0b67

Scatter Objects: replace deprecated bgl module

Part of T80730

===================================================================

M	object_scatter/__init__.py
M	object_scatter/operator.py

===================================================================

diff --git a/object_scatter/__init__.py b/object_scatter/__init__.py
index 12bc8ca0..8edeac71 100644
--- a/object_scatter/__init__.py
+++ b/object_scatter/__init__.py
@@ -3,8 +3,8 @@
 bl_info = {
     "name": "Scatter Objects",
     "author": "Jacques Lucke",
-    "version": (0, 1),
-    "blender": (2, 80, 0),
+    "version": (0, 2),
+    "blender": (3, 0, 0),
     "location": "3D View",
     "description": "Distribute object instances on another object.",
     "warning": "",
diff --git a/object_scatter/operator.py b/object_scatter/operator.py
index 07bf3884..8be78672 100644
--- a/object_scatter/operator.py
+++ b/object_scatter/operator.py
@@ -2,7 +2,6 @@
 
 import bpy
 import gpu
-import bgl
 import blf
 import math
 import enum
@@ -340,14 +339,14 @@ def draw_matrices_batches(batches):
     shader.bind()
     shader.uniform_float("color", (0.4, 0.4, 1.0, 0.3))
 
-    bgl.glEnable(bgl.GL_BLEND)
-    bgl.glDepthMask(bgl.GL_FALSE)
+    gpu.state.blend_set('ALPHA')
+    gpu.state.depth_mask_set(False)
 
     for batch in batches:
         batch.draw(shader)
 
-    bgl.glDisable(bgl.GL_BLEND)
-    bgl.glDepthMask(bgl.GL_TRUE)
+    gpu.state.blend_set('NONE')
+    gpu.state.depth_mask_set(True)
 
 def create_batch_for_matrices(matrices, base_scale):
     coords = []
@@ -367,7 +366,7 @@ def create_batch_for_matrices(matrices, base_scale):
 
 def draw_line_strip_batch(batch, color, thickness=1):
     shader = get_uniform_color_shader()
-    bgl.glLineWidth(thickness)
+    gpu.state.line_width_set(thickness)
     shader.bind()
     shader.uniform_float("color", color)
     batch.draw(shader)



More information about the Bf-extensions-cvs mailing list