mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-29 10:12:02 +05:30
Resolve issue with getting textures.
This commit is contained in:
parent
2f98c2a1a2
commit
b1b281cccd
@ -53,7 +53,7 @@ class TextureBatchDescriptor(ctypes.Structure):
|
|||||||
class Texture(ctypes.Structure):
|
class Texture(ctypes.Structure):
|
||||||
_pack_ = 1
|
_pack_ = 1
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
("data", ctypes.c_ubyte)
|
("data", ctypes.POINTER(ctypes.c_ubyte))
|
||||||
]
|
]
|
||||||
|
|
||||||
class TextureBatch(ctypes.Structure):
|
class TextureBatch(ctypes.Structure):
|
||||||
@ -305,16 +305,23 @@ class TEXtureBatchDescriptor:
|
|||||||
def gettexturesize(self):
|
def gettexturesize(self):
|
||||||
return self.cstruct.contents.textureSize
|
return self.cstruct.contents.textureSize
|
||||||
|
|
||||||
|
class TEXtureBatch:
|
||||||
# Needs testing / correction - gettextures will 'return by parameter'
|
def __init__(self, i, filedata):
|
||||||
# a dynamic array of textures. Need to be able to access multiple Texture()
|
self.cstruct = TextureBatch()
|
||||||
class TEXtures:
|
|
||||||
def __init__(self, i, count, filedata):
|
|
||||||
self.cstruct = ctypes.byref(Texture())
|
|
||||||
if filedata:
|
if filedata:
|
||||||
devil1tex.gettextures(self.cstruct, i, filedata, len(filedata))
|
self.cstruct.batch = None
|
||||||
|
tbd = TEXtureBatchDescriptor(i, filedata)
|
||||||
|
self.amount = tbd.gettexno()
|
||||||
|
memsize = self.amount * tbd.gettexturesize()
|
||||||
|
self.cstruct.batch = ctypes.cast(
|
||||||
|
ctypes.create_string_buffer(memsize),
|
||||||
|
ctypes.POINTER(Texture))
|
||||||
|
devil1tex.gettextures(self.cstruct.batch, i, filedata, len(filedata))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def gettextures(self):
|
||||||
|
return self.cstruct.batch[:self.amount]
|
||||||
|
|
||||||
class GEOHeader:
|
class GEOHeader:
|
||||||
def __init__(self, filedata):
|
def __init__(self, filedata):
|
||||||
self.cstruct = ctypes.pointer(Header())
|
self.cstruct = ctypes.pointer(Header())
|
||||||
@ -497,7 +504,11 @@ if __name__ == "__main__":
|
|||||||
tbd = TEXtureBatchDescriptor(1, data)
|
tbd = TEXtureBatchDescriptor(1, data)
|
||||||
tbd.show()
|
tbd.show()
|
||||||
print(tbd.gettexturesize())
|
print(tbd.gettexturesize())
|
||||||
tx = TEXtures(0, tbd.gettexno(), data)
|
#tx = TEXtures(0, tbd.gettexno(), data)
|
||||||
|
tx = TEXtureBatch(0, data)
|
||||||
|
ts = tx.gettextures()
|
||||||
|
for i in range(0, 10):
|
||||||
|
print(ts[0].data[i])
|
||||||
|
|
||||||
with open("pl00.pld_0", "rb") as f:
|
with open("pl00.pld_0", "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
Loading…
Reference in New Issue
Block a user