From 52de706a96760419a6b634281d02e022ccb9d437 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 17 May 2018 22:44:00 -0700 Subject: [PATCH] gettextures() returns list of writable byte arrays --- bindings/py3devil1tex.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bindings/py3devil1tex.py b/bindings/py3devil1tex.py index 1e77a24..dccf093 100644 --- a/bindings/py3devil1tex.py +++ b/bindings/py3devil1tex.py @@ -136,7 +136,8 @@ class pyTextureBatch: self.cstruct.batch = None tbd = pyTextureBatchDescriptor(i, filedata) self.amount = tbd.gettexnumber() - memsize = self.amount * tbd.gettexturesize() + self.size = tbd.gettexturesize() + memsize = self.amount * self.size self.cstruct.batch = ctypes.cast( ctypes.create_string_buffer(memsize), ctypes.POINTER(Texture)) @@ -149,5 +150,12 @@ class pyTextureBatch: return def gettextures(self): - return self.cstruct.batch[:self.amount] + ptrs = self.cstruct.batch[:self.amount] + textures = [] + for ptr in ptrs: + texture = ctypes.cast(ptr.data, + ctypes.POINTER( + ctypes.c_ubyte * self.size))[0] + textures.append(texture) + return textures