mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-25 16:28:57 +05:30
Added namespace structs for textures
This commit is contained in:
parent
40db88d4eb
commit
48f255eb36
@ -17,8 +17,8 @@ typedef struct {
|
||||
bool (* const getheader) (struct PldHeader*, const char*);
|
||||
int (* const sizeofsector)(struct PldHeader*, unsigned int, unsigned int);
|
||||
void (* const printheader) (struct PldHeader*);
|
||||
} namespace_struct;
|
||||
extern namespace_struct const DEVIL1PLD;
|
||||
} fn_devil1pld;
|
||||
extern fn_devil1pld const DEVIL1PLD;
|
||||
|
||||
// input: pointer to a struct, contents of the .pld file.
|
||||
// * = pass by reference of a struct PldHeader
|
||||
|
@ -38,32 +38,50 @@ struct TextureBatch {
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
void (* const printheader) (struct TexturePack*);
|
||||
void (* const printbatchdesc)(struct TextureBatchDescriptor*);
|
||||
bool (* const getbatchdesc) (struct TextureBatchDescriptor**,
|
||||
unsigned int,
|
||||
const char *,
|
||||
unsigned int);
|
||||
bool (* const getbatch) (struct TextureBatch**,
|
||||
unsigned int,
|
||||
const char*,
|
||||
unsigned int);
|
||||
bool (* const gettextures) (struct Texture*,
|
||||
unsigned int,
|
||||
const char*,
|
||||
const unsigned int);
|
||||
} fn_devil1tex;
|
||||
extern fn_devil1tex const DEVIL1TEX;
|
||||
|
||||
// -------------------------------------------------------+
|
||||
// Functions
|
||||
// -------------------------------------------------------+
|
||||
|
||||
// Print Texture Pack Header.
|
||||
void printtph(struct TexturePack*);
|
||||
static void printtph(struct TexturePack*);
|
||||
|
||||
// Print Texture Batch Descriptor.
|
||||
void printtbd(struct TextureBatchDescriptor*);
|
||||
static void printtbd(struct TextureBatchDescriptor*);
|
||||
|
||||
// Get Texture Batch Descriptor.
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
bool gettexdescriptor(struct TextureBatchDescriptor**,
|
||||
static bool gettexdescriptor(struct TextureBatchDescriptor**,
|
||||
unsigned int,
|
||||
const char *,
|
||||
unsigned int);
|
||||
|
||||
// Get Texture Batch.
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
bool gettexbatch(struct TextureBatch**,
|
||||
static bool gettexbatch(struct TextureBatch**,
|
||||
unsigned int,
|
||||
const char*,
|
||||
unsigned int);
|
||||
|
||||
// Unpack Texture Batch
|
||||
bool unpacktexbatch(struct Texture*,
|
||||
static bool unpacktexbatch(struct Texture*,
|
||||
unsigned int,
|
||||
const char*,
|
||||
const unsigned int);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "devil1pld.h"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace_struct const DEVIL1PLD = {getpldh, sizeofpldstruct, printpldh};
|
||||
fn_devil1pld const DEVIL1PLD = {getpldh, sizeofpldstruct, printpldh};
|
||||
|
||||
static bool getpldh(struct PldHeader *ph, const char *filedata) {
|
||||
bool good = false;
|
||||
|
@ -2,7 +2,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void printtph (struct TexturePack *tp) {
|
||||
fn_devil1tex const DEVIL1TEX = {printtph,
|
||||
printtbd,
|
||||
gettexdescriptor,
|
||||
gettexbatch,
|
||||
unpacktexbatch};
|
||||
|
||||
static void printtph (struct TexturePack *tp) {
|
||||
if (tp != NULL) {
|
||||
printf("id: \t %c %c %c %c \n", tp -> id[3],
|
||||
tp -> id[2],
|
||||
@ -15,7 +21,7 @@ void printtph (struct TexturePack *tp) {
|
||||
return;
|
||||
}
|
||||
|
||||
void printtbd(struct TextureBatchDescriptor *bd) {
|
||||
static void printtbd(struct TextureBatchDescriptor *bd) {
|
||||
if (bd != NULL) {
|
||||
printf("batch index: \t %i \n", bd -> batchIdx);
|
||||
printf("hash: \t %u \n", bd -> hash);
|
||||
@ -23,7 +29,7 @@ void printtbd(struct TextureBatchDescriptor *bd) {
|
||||
}
|
||||
}
|
||||
|
||||
bool gettexdescriptor(struct TextureBatchDescriptor **descriptor,
|
||||
static bool gettexdescriptor(struct TextureBatchDescriptor **descriptor,
|
||||
unsigned int i,
|
||||
const char *filedata,
|
||||
unsigned int filesize) {
|
||||
@ -38,7 +44,7 @@ bool gettexdescriptor(struct TextureBatchDescriptor **descriptor,
|
||||
return done;
|
||||
}
|
||||
|
||||
bool gettexbatch(struct TextureBatch **batch,
|
||||
static bool gettexbatch(struct TextureBatch **batch,
|
||||
unsigned int i,
|
||||
const char *filedata,
|
||||
unsigned int filesize) {
|
||||
@ -67,7 +73,7 @@ bool gettexbatch(struct TextureBatch **batch,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool unpacktexbatch(struct Texture *t,
|
||||
static bool unpacktexbatch(struct Texture *t,
|
||||
unsigned int i,
|
||||
const char *filedata,
|
||||
const unsigned int filesize) {
|
||||
|
@ -102,10 +102,10 @@ void exporttextures(const char *filedata,
|
||||
unsigned int j;
|
||||
unsigned int id = 0;
|
||||
for (i = 0; i < p -> batchNumber; i++) {
|
||||
gettexdescriptor(&d, i, filedata, filesize);
|
||||
DEVIL1TEX.getbatchdesc(&d, i, filedata, filesize);
|
||||
t = (struct Texture*)
|
||||
malloc(sizeof(struct Texture) * (d -> texNumber));
|
||||
unpacktexbatch(t, i, filedata, filesize);
|
||||
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);
|
||||
@ -144,8 +144,8 @@ int main(int argc, char ** argv) {
|
||||
unsigned int bufsize = 0;
|
||||
char *buffer = loadfile(f, &bufsize);
|
||||
// unpackpld(buffer, bufsize, f);
|
||||
// exporttextures(buffer, bufsize, f);
|
||||
extractmeshes(buffer, bufsize, f);
|
||||
exporttextures(buffer, bufsize, f);
|
||||
// extractmeshes(buffer, bufsize, f);
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user