Unpack textures has correct offsets for textures

This commit is contained in:
_
2018-04-04 21:49:32 -07:00
parent cff2209971
commit 24d4f920dc
3 changed files with 57 additions and 11 deletions

View File

@@ -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;
}