mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2025-05-31 14:11:42 +05:30
Unpack textures has correct offsets for textures
This commit is contained in:
@@ -56,23 +56,30 @@ void gettbd (struct TextureBatchDescriptor **descriptors,
|
||||
return;
|
||||
}
|
||||
|
||||
void gettexturebatch(struct TextureBatch **tb,
|
||||
// returns total count of textures in the file.
|
||||
unsigned int gettexturebatch(
|
||||
struct TextureBatch **tb,
|
||||
struct TextureBatchDescriptor **bds,
|
||||
const char *filedata,
|
||||
unsigned int filesize) {
|
||||
struct TexturePack *tp = (struct TexturePack*)filedata;
|
||||
struct TextureBatchDescriptor **bds = NULL;
|
||||
bds = (struct TextureBatchDescriptor**)malloc(tp -> batchNumber);
|
||||
gettbd(bds, filedata, filesize);
|
||||
// struct TextureBatchDescriptor **bds = NULL;
|
||||
// bds = (struct TextureBatchDescriptor**)malloc(tp -> batchNumber);
|
||||
// gettbd(bds, filedata, filesize);
|
||||
unsigned int offset = tp -> firstBatchOffset;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
unsigned int totaltextures = 0;
|
||||
// TextureBatch shares a starting address with the first texture
|
||||
// and shares the ending address with the last texture.
|
||||
for (i = 0; i < tp -> batchNumber; i++) {
|
||||
printf("%x \n", offset);
|
||||
tb[i] = (struct TextureBatch*)filedata + offset;
|
||||
// the next texture batch is TextureSize * number of textures away.
|
||||
offset += bds[i] -> textureSize * (bds[i] -> texNumber);
|
||||
offset += bds[i] -> textureSize * (bds[i] -> texNumber);
|
||||
totaltextures += bds[i] -> texNumber;
|
||||
}
|
||||
free(bds);
|
||||
// free(bds);
|
||||
return totaltextures;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user