mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-22 22:03:00 +05:30
Moved loop to its own function - gettextures()
This commit is contained in:
parent
91103da410
commit
6f915237b4
@ -51,4 +51,10 @@ unsigned int gettexturebatch(
|
|||||||
struct TextureBatchDescriptor**,
|
struct TextureBatchDescriptor**,
|
||||||
const char*,
|
const char*,
|
||||||
unsigned int);
|
unsigned int);
|
||||||
|
|
||||||
|
void gettextures(struct Texture **,
|
||||||
|
struct TexturePack*,
|
||||||
|
struct TextureBatch**,
|
||||||
|
struct TextureBatchDescriptor**);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -83,3 +83,22 @@ unsigned int gettexturebatch(
|
|||||||
return totaltextures;
|
return totaltextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gettextures(struct Texture **t,
|
||||||
|
struct TexturePack *tp,
|
||||||
|
struct TextureBatch **tb,
|
||||||
|
struct TextureBatchDescriptor **bds) {
|
||||||
|
unsigned int i;
|
||||||
|
unsigned int j;
|
||||||
|
// k is access to index of textures.
|
||||||
|
unsigned int k = 0;
|
||||||
|
unsigned int offset = 0;
|
||||||
|
for (i = 0; i < tp -> batchNumber; i++) {
|
||||||
|
for (j = 0; j < bds[i] -> texNumber; j++) {
|
||||||
|
printf("texture offsets %x\n", offset + tp -> firstBatchOffset);
|
||||||
|
t[k] = (struct Texture*)tb + offset;
|
||||||
|
offset += bds[i] -> textureSize;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
14
test/main.c
14
test/main.c
@ -126,19 +126,7 @@ void unpacktextures(const char *filedata,
|
|||||||
struct Texture **textures = NULL;
|
struct Texture **textures = NULL;
|
||||||
textures = (struct Texture**)malloc(
|
textures = (struct Texture**)malloc(
|
||||||
sizeof(struct Texture**) * texturecount);
|
sizeof(struct Texture**) * texturecount);
|
||||||
unsigned int i;
|
gettextures(textures, tp, batches, descripts);
|
||||||
unsigned int j;
|
|
||||||
// k is access to index of textures.
|
|
||||||
unsigned int k = 0;
|
|
||||||
unsigned int offset = 0;
|
|
||||||
for (i = 0; i < tp -> batchNumber; i++) {
|
|
||||||
for (j = 0; j < descripts[i] -> texNumber; j++) {
|
|
||||||
printf("texture offsets %x\n", offset + tp -> firstBatchOffset);
|
|
||||||
textures[k] = (struct Texture*)batches + offset;
|
|
||||||
offset += descripts[i] -> textureSize;
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(textures);
|
free(textures);
|
||||||
free(descripts);
|
free(descripts);
|
||||||
free(batches);
|
free(batches);
|
||||||
|
Loading…
Reference in New Issue
Block a user