mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-25 16:28:57 +05:30
Deleted scrapped functions.
This commit is contained in:
parent
5462ec025e
commit
0dabc2568e
@ -68,23 +68,4 @@ bool unpacktexbatch(struct Texture*,
|
|||||||
const char*,
|
const char*,
|
||||||
const unsigned int);
|
const unsigned int);
|
||||||
|
|
||||||
// -------------------------------------------------------+
|
|
||||||
// Retired Functions
|
|
||||||
// These require the client allocate more on the heap.
|
|
||||||
// -------------------------------------------------------+
|
|
||||||
|
|
||||||
void gettbd(struct TextureBatchDescriptor**,
|
|
||||||
const char*,
|
|
||||||
unsigned int);
|
|
||||||
|
|
||||||
unsigned int gettexturebatch(
|
|
||||||
struct TextureBatch**,
|
|
||||||
struct TextureBatchDescriptor**,
|
|
||||||
const char*,
|
|
||||||
unsigned int);
|
|
||||||
|
|
||||||
void locatetextures(unsigned int*,
|
|
||||||
struct TexturePack*,
|
|
||||||
struct TextureBatchDescriptor**);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,82 +90,6 @@ bool unpacktexbatch(struct Texture *t,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------+
|
|
||||||
// Retired Functions
|
|
||||||
// -------------------------------------------------------+
|
|
||||||
|
|
||||||
|
|
||||||
// get texture pack descriptors
|
|
||||||
void gettbd (struct TextureBatchDescriptor **descriptors,
|
|
||||||
const char *filedata,
|
|
||||||
unsigned int filesize) {
|
|
||||||
if (descriptors == NULL || filedata == NULL || filesize <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct TexturePack *tp = NULL;
|
|
||||||
tp = (struct TexturePack*)filedata;
|
|
||||||
if (filesize <= (sizeof(struct TextureBatchDescriptor)
|
|
||||||
* tp -> batchNumber
|
|
||||||
+ sizeof(struct TexturePack))){
|
|
||||||
fprintf(stderr,
|
|
||||||
"File Error: file size to struct sizes ratio.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
unsigned int index = sizeof(struct TexturePack);
|
|
||||||
// Batch Descriptors are structured one after another.
|
|
||||||
// therefore the next one is at
|
|
||||||
// current index + sizeof(TextureBatchDescriptor)
|
|
||||||
unsigned int i = 0;
|
|
||||||
do {
|
|
||||||
index = sizeof(struct TextureBatchDescriptor) * i
|
|
||||||
+ sizeof(struct TexturePack);
|
|
||||||
printf("batch descriptor start: %x\n", index);
|
|
||||||
descriptors[i] = (struct TextureBatchDescriptor*)
|
|
||||||
(filedata + index);
|
|
||||||
i++;
|
|
||||||
} while(i < (tp -> batchNumber));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
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++) {
|
|
||||||
tb[i] = (struct TextureBatch*)filedata + offset;
|
|
||||||
// the next texture batch is TextureSize * number of textures away.
|
|
||||||
offset += bds[i] -> textureSize * (bds[i] -> texNumber);
|
|
||||||
totaltextures += bds[i] -> texNumber;
|
|
||||||
}
|
|
||||||
return totaltextures;
|
|
||||||
}
|
|
||||||
|
|
||||||
void locatetextures(unsigned int *t,
|
|
||||||
struct TexturePack *tp,
|
|
||||||
struct TextureBatchDescriptor **bds) {
|
|
||||||
unsigned int i;
|
|
||||||
unsigned int j;
|
|
||||||
// k is access to index of textures.
|
|
||||||
unsigned int k = 0;
|
|
||||||
unsigned int offset = tp -> firstBatchOffset;
|
|
||||||
for (i = 0; i < tp -> batchNumber; i++) {
|
|
||||||
for (j = 0; j < bds[i] -> texNumber; j++) {
|
|
||||||
t[k] = offset;
|
|
||||||
offset += bds[i] -> textureSize;
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
32
test/main.c
32
test/main.c
@ -107,38 +107,6 @@ void write(const char *filename,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unpacktextures(const char *filedata,
|
|
||||||
unsigned int filesize,
|
|
||||||
const char *filename) {
|
|
||||||
struct TexturePack *tp = (struct TexturePack*)filedata;
|
|
||||||
struct TextureBatch **batches = NULL;
|
|
||||||
struct TextureBatchDescriptor **descripts = NULL;
|
|
||||||
batches = (struct TextureBatch**)malloc(tp -> batchNumber);
|
|
||||||
descripts = (struct TextureBatchDescriptor**)malloc(tp -> batchNumber);
|
|
||||||
gettbd(descripts, filedata, filesize);
|
|
||||||
// array of pointers - texture data exists in memory in filedata.
|
|
||||||
unsigned int texturecount = gettexturebatch(batches,
|
|
||||||
descripts,
|
|
||||||
filedata,
|
|
||||||
filesize);
|
|
||||||
unsigned int *tloc = (unsigned int*)
|
|
||||||
malloc(sizeof(unsigned int) * texturecount);
|
|
||||||
locatetextures(tloc, tp, descripts);
|
|
||||||
// add 3 to buffer for digits, & 4 for file extension
|
|
||||||
char *fmt = (char*)malloc(strlen(filename) + 3 + 4);
|
|
||||||
unsigned int texsize = 0;
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < texturecount; i++) {
|
|
||||||
texsize = descripts[i/(tp -> batchNumber)] -> textureSize;
|
|
||||||
sprintf(fmt, "%s_%d.dds", filename, i);
|
|
||||||
write(fmt, filedata + tloc[i], texsize);
|
|
||||||
}
|
|
||||||
free(fmt);
|
|
||||||
free(tloc);
|
|
||||||
free(descripts);
|
|
||||||
free(batches);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exporttextures(const char *filedata,
|
void exporttextures(const char *filedata,
|
||||||
unsigned int filesize,
|
unsigned int filesize,
|
||||||
const char *filename) {
|
const char *filename) {
|
||||||
|
Loading…
Reference in New Issue
Block a user