Added example of getting all textures

This commit is contained in:
2018-04-25 04:12:48 -07:00
parent 4bed12289b
commit b2ddc14a63

View File

@ -97,3 +97,32 @@ Functions
true on success. true on success.
false when failing checks against segmentation faults. false when failing checks against segmentation faults.
Example logic to extract all textures:
{
// After reading the file in...
// Need to know how many batches are in the package.
struct TexturePack *p = (struct TexturePack*)filedata;
// Need to know about each batch in the package.
struct TextureBatchDescriptor *d = NULL;
struct Texture *t = NULL;
unsigned int i;
for (i = 0; i < p -> batchNumber; i++) {
DEVIL1TEX.getbatchdesc(&d, i, filedata, filesize);
// Batch descriptor tells how many textures are in the batch.
t = (struct Texture*)
malloc(sizeof(struct Texture) * (d -> texNumber));
DEVIL1TEX.gettextures(t, i, filedata, filesize);
// There are now textures in 't'.
for (j = 0; j < d -> texNumber; j++) {
// Do whatever you want with however many of them there are.
}
}
}