Skip to content
Snippets Groups Projects
Commit 5578ae83 authored by Germano Cavalcante's avatar Germano Cavalcante
Browse files

UV Layout: replace deprecated bgl module

Part of T80730
parent bb77e697
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
bl_info = { bl_info = {
"name": "UV Layout", "name": "UV Layout",
"author": "Campbell Barton, Matt Ebb", "author": "Campbell Barton, Matt Ebb",
"version": (1, 1, 4), "version": (1, 1, 5),
"blender": (3, 0, 0), "blender": (3, 0, 0),
"location": "UV Editor > UV > Export UV Layout", "location": "UV Editor > UV > Export UV Layout",
"description": "Export the UV layout as a 2D graphic", "description": "Export the UV layout as a 2D graphic",
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import bpy import bpy
import gpu import gpu
import bgl
from mathutils import Vector, Matrix from mathutils import Vector, Matrix
from mathutils.geometry import tessellate_polygon from mathutils.geometry import tessellate_polygon
from gpu_extras.batch import batch_for_shader from gpu_extras.batch import batch_for_shader
...@@ -26,10 +25,7 @@ def export(filepath, face_data, colors, width, height, opacity): ...@@ -26,10 +25,7 @@ def export(filepath, face_data, colors, width, height, opacity):
def draw_image(face_data, opacity): def draw_image(face_data, opacity):
bgl.glLineWidth(1) gpu.state.blend_set('ALPHA')
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_LINE_SMOOTH)
bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
with gpu.matrix.push_pop(): with gpu.matrix.push_pop():
gpu.matrix.load_matrix(get_normalize_uvs_matrix()) gpu.matrix.load_matrix(get_normalize_uvs_matrix())
...@@ -38,8 +34,7 @@ def draw_image(face_data, opacity): ...@@ -38,8 +34,7 @@ def draw_image(face_data, opacity):
draw_background_colors(face_data, opacity) draw_background_colors(face_data, opacity)
draw_lines(face_data) draw_lines(face_data)
bgl.glDisable(bgl.GL_BLEND) gpu.state.blend_set('NONE')
bgl.glDisable(bgl.GL_LINE_SMOOTH)
def get_normalize_uvs_matrix(): def get_normalize_uvs_matrix():
...@@ -85,11 +80,12 @@ def draw_lines(face_data): ...@@ -85,11 +80,12 @@ def draw_lines(face_data):
coords.append((start[0], start[1])) coords.append((start[0], start[1]))
coords.append((end[0], end[1])) coords.append((end[0], end[1]))
shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') shader = gpu.shader.from_builtin('POLYLINE_UNIFORM_COLOR')
shader.bind() shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:])
shader.uniform_float("color", (0, 0, 0, 1)) shader.uniform_float("lineWidth", 1.0)
batch = batch_for_shader(shader, 'LINES', {"pos": coords}) shader.uniform_float("color", (0.0, 0.0, 0.0, 1.0))
batch = batch_for_shader(shader, 'LINES', {"pos": coords})
batch.draw(shader) batch.draw(shader)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment