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:
Diffstat (limited to 'measureit')
-rw-r--r--measureit/__init__.py4
-rw-r--r--measureit/measureit_geometry.py7
-rw-r--r--measureit/measureit_main.py9
-rw-r--r--measureit/measureit_render.py10
4 files changed, 13 insertions, 17 deletions
diff --git a/measureit/__init__.py b/measureit/__init__.py
index 8d4b9576..c7f4fc7e 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 a1e90b9e..56efad0e 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 23e9de46..d69ba268 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 efc5c1b0..093149d5 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()