From f1e64d1d58ac184633d4f69470fc92146174e914 Mon Sep 17 00:00:00 2001 From: Germano Date: Fri, 15 Sep 2017 16:11:27 -0300 Subject: snap_context module: alloc the smallest possible size in `np_array_as_bgl_Buffer(array)` --- modules/snap_context/bgl_ext.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3