Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-09-22 02:25:59 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-09-22 02:38:06 +0300
commit5578ae83b3f318c9f40f55aed12fd2dbca514eaa (patch)
treeada7faa70b33f23a6211ea1e77d1d3b1e76a7a75
parentbb77e697e13e324204b9b8026a29d7dc07e98bd2 (diff)
UV Layout: replace deprecated bgl module
Part of T80730
-rw-r--r--io_mesh_uv_layout/__init__.py2
-rw-r--r--io_mesh_uv_layout/export_uv_png.py18
2 files changed, 8 insertions, 12 deletions
diff --git a/io_mesh_uv_layout/__init__.py b/io_mesh_uv_layout/__init__.py
index bb7e4584..7145384c 100644
--- a/io_mesh_uv_layout/__init__.py
+++ b/io_mesh_uv_layout/__init__.py
@@ -3,7 +3,7 @@
bl_info = {
"name": "UV Layout",
"author": "Campbell Barton, Matt Ebb",
- "version": (1, 1, 4),
+ "version": (1, 1, 5),
"blender": (3, 0, 0),
"location": "UV Editor > UV > Export UV Layout",
"description": "Export the UV layout as a 2D graphic",
diff --git a/io_mesh_uv_layout/export_uv_png.py b/io_mesh_uv_layout/export_uv_png.py
index 2c40abdf..ad1b2284 100644
--- a/io_mesh_uv_layout/export_uv_png.py
+++ b/io_mesh_uv_layout/export_uv_png.py
@@ -2,7 +2,6 @@
import bpy
import gpu
-import bgl
from mathutils import Vector, Matrix
from mathutils.geometry import tessellate_polygon
from gpu_extras.batch import batch_for_shader
@@ -26,10 +25,7 @@ def export(filepath, face_data, colors, width, height, opacity):
def draw_image(face_data, opacity):
- bgl.glLineWidth(1)
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glEnable(bgl.GL_LINE_SMOOTH)
- bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
+ gpu.state.blend_set('ALPHA')
with gpu.matrix.push_pop():
gpu.matrix.load_matrix(get_normalize_uvs_matrix())
@@ -38,8 +34,7 @@ def draw_image(face_data, opacity):
draw_background_colors(face_data, opacity)
draw_lines(face_data)
- bgl.glDisable(bgl.GL_BLEND)
- bgl.glDisable(bgl.GL_LINE_SMOOTH)
+ gpu.state.blend_set('NONE')
def get_normalize_uvs_matrix():
@@ -85,11 +80,12 @@ def draw_lines(face_data):
coords.append((start[0], start[1]))
coords.append((end[0], end[1]))
- shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
- shader.bind()
- shader.uniform_float("color", (0, 0, 0, 1))
- batch = batch_for_shader(shader, 'LINES', {"pos": coords})
+ shader = gpu.shader.from_builtin('POLYLINE_UNIFORM_COLOR')
+ shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:])
+ shader.uniform_float("lineWidth", 1.0)
+ shader.uniform_float("color", (0.0, 0.0, 0.0, 1.0))
+ batch = batch_for_shader(shader, 'LINES', {"pos": coords})
batch.draw(shader)