diff --git a/measureit/__init__.py b/measureit/__init__.py index 8d4b95769902c78d5fcbb042f49141c1eed65107..c7f4fc7e681155069485a1d100c4d96afa2819f6 100644 --- a/measureit/__init__.py +++ b/measureit/__init__.py @@ -11,8 +11,8 @@ bl_info = { "name": "MeasureIt", "author": "Antonio Vazquez (antonioya)", "location": "View3D > Sidebar > View Tab", - "version": (1, 8, 1), - "blender": (2, 80, 0), + "version": (1, 8, 2), + "blender": (3, 0, 0), "description": "Tools for measuring objects.", "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/measureit.html", "category": "3D View" diff --git a/measureit/measureit_geometry.py b/measureit/measureit_geometry.py index a1e90b9ed8e747b1adf3c97d986256b051145a00..56efad0e31e1a77226309b5b8267c79eb53b4812 100644 --- a/measureit/measureit_geometry.py +++ b/measureit/measureit_geometry.py @@ -17,7 +17,6 @@ from bpy_extras import view3d_utils, mesh_utils import bpy_extras.object_utils as object_utils from sys import exc_info # GPU -import bgl import gpu from gpu_extras.batch import batch_for_shader @@ -477,7 +476,7 @@ def draw_segments(context, myobj, op, region, rv3d): # ------------------------------------ # Draw lines # ------------------------------------ - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') if ms.gltype == 1: # Segment draw_line(screen_point_ap1, screen_point_v11, rgba) @@ -1175,7 +1174,7 @@ def draw_faces(context, myobj, region, rv3d): a_p2 = (a_p1[0] + normal[0] * ln, a_p1[1] + normal[1] * ln, a_p1[2] + normal[2] * ln) # line setup - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') imm_set_line_width(th) # converting to screen coordinates txtpoint2d = get_2d_point(region, rv3d, a_p1) @@ -1185,7 +1184,7 @@ def draw_faces(context, myobj, region, rv3d): draw_text(myobj, txtpoint2d, str(f.index), rgba, fsize) # Draw Normal if scene.measureit_debug_normals is True: - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set('ALPHA') draw_arrow(txtpoint2d, point2, rgba, 10, "99", "1") if len(obverts) > 2 and scene.measureit_debug_normal_details is True: diff --git a/measureit/measureit_main.py b/measureit/measureit_main.py index 23e9de461204f943e4f9e20e958c191ccd11052c..d69ba268ec34f35b4856538b6470540f146e0fba 100644 --- a/measureit/measureit_main.py +++ b/measureit/measureit_main.py @@ -11,7 +11,6 @@ import bpy import bmesh from bmesh import from_edit_mesh # noinspection PyUnresolvedReferences -import bgl from bpy.types import PropertyGroup, Panel, Object, Operator, SpaceView3D from bpy.props import IntProperty, CollectionProperty, FloatVectorProperty, BoolProperty, StringProperty, \ FloatProperty, EnumProperty @@ -1933,8 +1932,8 @@ def draw_main(context): else: objlist = context.view_layer.objects - # Enable GL drawing - bgl.glEnable(bgl.GL_BLEND) + # Enable drawing + gpu.state.blend_set('ALPHA') # --------------------------------------- # Generate all OpenGL calls for measures # --------------------------------------- @@ -1964,9 +1963,9 @@ def draw_main(context): draw_faces(context, myobj, region, rv3d) # ----------------------- - # restore opengl defaults + # restore defaults # ----------------------- - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set('NONE') # ------------------------------------------------------------- diff --git a/measureit/measureit_render.py b/measureit/measureit_render.py index efc5c1b00b31c2a2ab6b32d9a8bec8a5c50600ea..093149d5cfc7774bebf14e5ad5a20e281f2dbdf7 100644 --- a/measureit/measureit_render.py +++ b/measureit/measureit_render.py @@ -8,7 +8,6 @@ # noinspection PyUnresolvedReferences import bpy import gpu -import bgl # noinspection PyUnresolvedReferences import blf from os import path, remove @@ -54,8 +53,8 @@ def render_main(self, context, animation=False): [0, 0, 0, 1]]) with offscreen.bind(): - bgl.glClearColor(0.0, 0.0, 0.0, 0.0) - bgl.glClear(bgl.GL_COLOR_BUFFER_BIT) + fb = gpu.state.active_framebuffer_get() + fb.clear(color=(0.0, 0.0, 0.0, 0.0)) gpu.matrix.reset() gpu.matrix.load_matrix(view_matrix) gpu.matrix.load_projection_matrix(Matrix.Identity(4)) @@ -101,9 +100,8 @@ def render_main(self, context, animation=False): y2 = height - y1 draw_rectangle((x1, y1), (x2, y2), rfcolor) - buffer = bgl.Buffer(bgl.GL_BYTE, width * height * 4) - bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0) - bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer) + buffer = fb.read_color(0, 0, width, height, 4, 0, 'UBYTE') + buffer.dimensions = width * height * 4 offscreen.free()