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 <germano.costa@ig.com.br>2017-09-15 22:11:27 +0300
committerGermano <germano.costa@ig.com.br>2017-09-15 22:11:27 +0300
commitf1e64d1d58ac184633d4f69470fc92146174e914 (patch)
tree44bf1323be1b783cf6601f43618cae325c764ac6 /modules
parent7c2d2fb096f5899f82c16e3d81039f38335dd1be (diff)
snap_context module: alloc the smallest possible size in `np_array_as_bgl_Buffer(array)`
Diffstat (limited to 'modules')
-rw-r--r--modules/snap_context/bgl_ext.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/snap_context/bgl_ext.py b/modules/snap_context/bgl_ext.py
index f8dbff09..b36238f7 100644
--- a/modules/snap_context/bgl_ext.py
+++ b/modules/snap_context/bgl_ext.py
@@ -95,7 +95,7 @@ def np_array_as_bgl_Buffer(array):
_decref.argtypes = _incref.argtypes = [ctypes.py_object]
_decref.restype = _incref.restype = None
- buf = bgl.Buffer(bgl.GL_BYTE, (1, *array.shape))[0]
+ buf = bgl.Buffer(bgl.GL_BYTE, ((1,) * (len(array.shape) + 1)))[0]
c_buf = C_Buffer.from_address(id(buf))
_decref(c_buf.parent)
@@ -103,6 +103,8 @@ def np_array_as_bgl_Buffer(array):
c_buf.parent = array # Prevents MEM_freeN
c_buf.type = type
+ for i, n in enumerate(array.shape):
+ c_buf.dimensions[i] = n
c_buf.buf = array.ctypes.data
return buf