Renamed demo files to be explicit about functionality.

This commit is contained in:
_
2018-04-18 00:21:34 -07:00
parent ec6e972688
commit 913998e37f
3 changed files with 0 additions and 0 deletions

44
demo/extracttexture.c Normal file
View File

@@ -0,0 +1,44 @@
#include "common.h"
#include "devil1tex.h"
void extracttextures(const char *filedata,
unsigned int filesize,
const char *filename) {
struct TexturePack *p = NULL;
struct Texture *t = NULL;
struct TextureBatchDescriptor *d = NULL;
char * fmt = NULL;
if (filedata == NULL || filesize == 0) {
return;
}
p = (struct TexturePack*)filedata;
fmt = (char*)malloc(strlen(filename) + 3 + 4);
unsigned int i;
unsigned int j;
unsigned int id = 0;
for (i = 0; i < p -> batchNumber; i++) {
DEVIL1TEX.getbatchdesc(&d, i, filedata, filesize);
t = (struct Texture*)
malloc(sizeof(struct Texture) * (d -> texNumber));
DEVIL1TEX.gettextures(t, i, filedata, filesize);
for (j = 0; j < d -> texNumber; j++) {
sprintf(fmt, "%s_%d.dds", filename, id);
write(fmt, t[j].data, d -> textureSize);
id++;
}
free(t);
}
free(fmt);
return;
}
int main(int argc, char ** argv) {
char *f = argv[1];
unsigned int bufsize = 0;
char *buffer = loadfile(f, &bufsize);
extracttextures(buffer, bufsize, f);
free(buffer);
return 0;
}