[Bf-extensions-cvs] [af946274] master: Sun position: replace deprecated bgl module by gpu T80730

Damien Picard noreply at git.blender.org
Wed May 26 01:07:33 CEST 2021


Commit: af94627460560da0f5fd03a7bb8897228d0b4c56
Author: Damien Picard
Date:   Wed May 26 00:04:48 2021 +0200
Branches: master
https://developer.blender.org/rBAaf94627460560da0f5fd03a7bb8897228d0b4c56

Sun position: replace deprecated bgl module by gpu T80730

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

M	sun_position/__init__.py
M	sun_position/hdr.py
M	sun_position/north.py

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

diff --git a/sun_position/__init__.py b/sun_position/__init__.py
index 0b15602b..e59a0932 100644
--- a/sun_position/__init__.py
+++ b/sun_position/__init__.py
@@ -34,8 +34,8 @@
 bl_info = {
     "name": "Sun Position",
     "author": "Michael Martin",
-    "version": (3, 1, 1),
-    "blender": (2, 80, 0),
+    "version": (3, 1, 2),
+    "blender": (3, 0, 0),
     "location": "World > Sun Position",
     "description": "Show sun position with objects and/or sky texture",
     "doc_url": "{BLENDER_MANUAL_URL}/addons/lighting/sun_position.html",
diff --git a/sun_position/hdr.py b/sun_position/hdr.py
index 27d6dca2..6bbd0042 100644
--- a/sun_position/hdr.py
+++ b/sun_position/hdr.py
@@ -20,7 +20,6 @@
 
 import bpy
 import gpu
-import bgl
 from gpu_extras.batch import batch_for_shader
 from mathutils import Vector
 from math import sqrt, pi, atan2, asin
@@ -60,6 +59,7 @@ def draw_callback_px(self, context):
     nt = context.scene.world.node_tree.nodes
     env_tex_node = nt.get(context.scene.sun_pos_properties.hdr_texture)
     image = env_tex_node.image
+    texture = gpu.texture.from_image(image)
 
     if self.area != context.area:
         return
@@ -82,16 +82,12 @@ def draw_callback_px(self, context):
         {"pos" : coords,
          "texCoord" : uv_coords})
 
-    bgl.glActiveTexture(bgl.GL_TEXTURE0)
-    bgl.glBindTexture(bgl.GL_TEXTURE_2D, image.bindcode)
-
-
     with gpu.matrix.push_pop():
         gpu.matrix.translate(position)
         gpu.matrix.scale(scale)
 
         shader.bind()
-        shader.uniform_int("image", 0)
+        shader.uniform_sampler("image", texture)
         shader.uniform_float("exposure", self.exposure)
         batch.draw(shader)
 
diff --git a/sun_position/north.py b/sun_position/north.py
index 0dbe7e4e..0c0a41af 100644
--- a/sun_position/north.py
+++ b/sun_position/north.py
@@ -17,7 +17,6 @@
 # ##### END GPL LICENSE BLOCK #####
 
 import bpy
-import bgl
 import math
 import gpu
 from gpu_extras.batch import batch_for_shader
@@ -94,10 +93,9 @@ else:
         shader.uniform_float("u_ViewProjectionMatrix", matrix)
         shader.uniform_float("u_Resolution", (bpy.context.region.width, bpy.context.region.height))
         shader.uniform_float("u_Color", color)
-        bgl.glLineWidth(2.0)
+        gpu.state.line_width_set(2.0)
         batch.draw(shader)
 
-
     _handle = None



More information about the Bf-extensions-cvs mailing list