Implemented getTextureBatch()

This commit is contained in:
_
2018-04-04 19:38:30 -07:00
parent a446dd8741
commit cff2209971
3 changed files with 40 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
#include "devil1tex.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void printtph (struct TexturePack *tp) {
@@ -55,3 +56,23 @@ void gettbd (struct TextureBatchDescriptor **descriptors,
return;
}
void gettexturebatch(struct TextureBatch **tb,
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);
unsigned int offset = tp -> firstBatchOffset;
unsigned int i;
unsigned int j;
// 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);
}
free(bds);
}