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:
authorAntonioya <blendergit@gmail.com>2018-12-06 19:42:46 +0300
committerAntonioya <blendergit@gmail.com>2018-12-06 19:43:12 +0300
commitc62dc337654e41a03dbe944dc0001acd8811fb15 (patch)
tree17c12583ca07ce9e18d18faaf7f814c36b8e51e6 /measureit
parentc3c0fd18ee1d58f8c9e7b03329894503afffa732 (diff)
MeasureIt: Fix render result.
Thanks to Jacques Lucke for help me to fix this area.
Diffstat (limited to 'measureit')
-rw-r--r--measureit/measureit_render.py43
1 files changed, 7 insertions, 36 deletions
diff --git a/measureit/measureit_render.py b/measureit/measureit_render.py
index 212d12be..dd7826a4 100644
--- a/measureit/measureit_render.py
+++ b/measureit/measureit_render.py
@@ -65,14 +65,17 @@ def render_main(self, context, animation=False):
# Loop to draw all lines in Offsecreen
# --------------------------------------
offscreen = gpu.types.GPUOffScreen(width, height)
- view_matrix = scene.camera.matrix_world.inverted()
- projection_matrix = scene.camera.calc_matrix_camera(context.depsgraph, x=width, y=height)
+ view_matrix = Matrix([
+ [2 / width, 0, 0, -1],
+ [0, 2 / height, 0, -1],
+ [0, 0, 1, 0],
+ [0, 0, 0, 1]])
with offscreen.bind():
bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)
gpu.matrix.reset()
gpu.matrix.load_matrix(view_matrix)
- gpu.matrix.load_projection_matrix(projection_matrix)
+ gpu.matrix.load_projection_matrix(Matrix.Identity(4))
# -----------------------------
# Loop to draw all objects
@@ -116,7 +119,7 @@ def render_main(self, context, animation=False):
draw_rectangle((x1, y1), (x2, y2), rfcolor)
buffer = bgl.Buffer(bgl.GL_BYTE, width * height * 4)
- bgl.glReadBuffer(bgl.GL_BACK)
+ bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0)
bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)
offscreen.free()
@@ -150,38 +153,6 @@ def render_main(self, context, animation=False):
settings.color_depth = depth
-# --------------------------------------------------------------------
-# Get the final render image and return as image object
-#
-# return None if no render available
-# --------------------------------------------------------------------
-def get_render_image(outpath):
- saved = False
- # noinspection PyBroadException
- try:
- # noinspection PyBroadException
- try:
- result = bpy.data.images['Render Result']
- if result.has_data is False:
- # this save produce to fill data image
- result.save_render(outpath)
- saved = True
- except:
- print("No render image found")
- return None
-
- # Save and reload
- if saved is False:
- result.save_render(outpath)
-
- img = img_utils.load_image(outpath)
-
- return img
- except:
- print("Unexpected render image error")
- return None
-
-
# -------------------------------------
# Save image to file
# -------------------------------------