mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 13:53:02 +05:30
Implemented getTextureBatch()
This commit is contained in:
parent
a446dd8741
commit
cff2209971
@ -46,4 +46,7 @@ void gettbd(struct TextureBatchDescriptor**,
|
||||
const char*,
|
||||
unsigned int);
|
||||
|
||||
void gettexturebatch(struct TextureBatch**,
|
||||
const char*,
|
||||
unsigned int);
|
||||
#endif
|
||||
|
@ -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);
|
||||
}
|
||||
|
30
test/main.c
30
test/main.c
@ -90,28 +90,30 @@ bool unpackpld (const char *filedata,
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
char *f = argv[1];
|
||||
unsigned int bufsize = 0;
|
||||
char *buffer = loadfile(f, &bufsize);
|
||||
// unpackpld(buffer, bufsize, f);
|
||||
struct TexturePack *tp = NULL;
|
||||
printf("%d %d %d %d \n", buffer[0],
|
||||
buffer[1],
|
||||
buffer[2],
|
||||
buffer[3]);
|
||||
tp = (struct TexturePack*)buffer;
|
||||
/* void unpacktextures(const char *filedata, unsigned int filesize) {
|
||||
struct TexturePack *tp = (struct TexturePack*)filedata;
|
||||
struct TextureBatchDescriptor **bds = NULL;
|
||||
bds = (struct TextureBatchDescriptor**)malloc(tp -> batchNumber);
|
||||
gettbd(bds, buffer, bufsize);
|
||||
gettbd(bds, filedata, filesize);
|
||||
printtph(tp);
|
||||
int i;
|
||||
for (i = 0; i < tp -> batchNumber; i++) {
|
||||
printtbd(bds[i]);
|
||||
}
|
||||
free(bds);
|
||||
return;
|
||||
} */
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
char *f = argv[1];
|
||||
unsigned int bufsize = 0;
|
||||
char *buffer = loadfile(f, &bufsize);
|
||||
// unpackpld(buffer, bufsize, f);
|
||||
// unpacktextures(buffer, bufsize);
|
||||
struct TexturePack *tp = (struct TexturePack*)buffer;
|
||||
struct TextureBatch **batches = NULL;
|
||||
batches = (struct TextureBatch**)malloc(tp -> batchNumber);
|
||||
gettexturebatch(batches, buffer, bufsize);
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user