[Bf-extensions-cvs] [f1e64d1d] master: snap_context module: alloc the smallest possible size in `np_array_as_bgl_Buffer(array)`
Germano
noreply at git.blender.org
Fri Sep 15 21:11:39 CEST 2017
Commit: f1e64d1d58ac184633d4f69470fc92146174e914
Author: Germano
Date: Fri Sep 15 16:11:27 2017 -0300
Branches: master
https://developer.blender.org/rBAf1e64d1d58ac184633d4f69470fc92146174e914
snap_context module: alloc the smallest possible size in `np_array_as_bgl_Buffer(array)`
===================================================================
M modules/snap_context/bgl_ext.py
===================================================================
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
More information about the Bf-extensions-cvs
mailing list