From 479000461e3b72a2f816589d65d8e017d5244a9f Mon Sep 17 00:00:00 2001 From: outfrost Date: Mon, 5 Nov 2018 03:11:35 +0100 Subject: [PATCH] Return aiScene* from import, move prints to debugutil --- debugutil.c | 32 ++++++++++++++++++++++++++++++++ debugutil.h | 5 +++++ level.c | 21 ++++----------------- level.h | 1 + 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/debugutil.c b/debugutil.c index 143c738..cd911b9 100644 --- a/debugutil.c +++ b/debugutil.c @@ -2,6 +2,7 @@ #include #include #include +#include char * get_gl_info() { const char * gl_version = (const char *) glGetString(GL_VERSION); @@ -22,3 +23,34 @@ char * get_gl_info() { return gl_info; } + +void print_struct_aiScene(FILE* stream, const struct aiScene* scene) { + if (scene == NULL) { + fprintf(stream, "NULL"); + return; + } + fprintf(stream, "{ mFlags = %u, mRootNode = %p, mNumMeshes = %u, mMeshes = %p, mNumMaterials = %u, mMaterials = %p, mNumAnimations = %u, mAnimations = %p, mNumTextures = %u, mTextures = %p, mNumLights = %u, mLights = %p }", + (*scene).mFlags, + (void*) (*scene).mRootNode, + (*scene).mNumMeshes, + (void*) (*scene).mMeshes, + (*scene).mNumMaterials, + (void*) (*scene).mMaterials, + (*scene).mNumAnimations, + (void*) (*scene).mAnimations, + (*scene).mNumTextures, + (void*) (*scene).mTextures, + (*scene).mNumLights, + (void*) (*scene).mLights); +} + +void print_struct_aiNode(FILE* stream, const struct aiNode* node) { + if (node == NULL) { + fprintf(stream, "NULL"); + return; + } + fprintf(stream, "{ mName = %s, mNumMeshes = %u, mMeshes = %p }", + (*node).mName.data, + (*node).mNumMeshes, + (void*) (*node).mMeshes); +} diff --git a/debugutil.h b/debugutil.h index f2b4e69..2d7793b 100644 --- a/debugutil.h +++ b/debugutil.h @@ -1,6 +1,11 @@ #ifndef DEBUGUTIL_H_ #define DEBUGUTIL_H_ +#include +#include + char * get_gl_info(); +void print_struct_aiScene(FILE* stream, const struct aiScene* scene); +void print_struct_aiNode(FILE* stream, const struct aiNode* node); #endif diff --git a/level.c b/level.c index 9f9b240..2c9dba2 100644 --- a/level.c +++ b/level.c @@ -23,24 +23,11 @@ void set_image(TGAimage* image) { level_image = image; } -void import_model(const char* path) { +const struct aiScene* import_model(const char* path) { const struct aiScene* scene = aiImportFile(path, 0u); if (scene == NULL) { - printf("We have nothing.\n"); - return; + fprintf(stderr, "Asset import failed at file %s\n", path); // TODO factor logging the heck outta here } - printf("mFlags = %u\nmRootNode = %p\nmNumMeshes = %u\nmMeshes = %p\nmNumMaterials = %u\nmMaterials = %p\nmNumAnimations = %u\nmAnimations = %p\nmNumTextures = %u\nmTextures = %p\nmNumLights = %u\nmLights = %p\n", - (*scene).mFlags, - (*scene).mRootNode, - (*scene).mNumMeshes, - (*scene).mMeshes, - (*scene).mNumMaterials, - (*scene).mMaterials, - (*scene).mNumAnimations, - (*scene).mAnimations, - (*scene).mNumTextures, - (*scene).mTextures, - (*scene).mNumLights, - (*scene).mLights); - aiReleaseImport(scene); + return scene; + // TODO aiReleaseImport(scene); } diff --git a/level.h b/level.h index 84d2c6a..fe27494 100644 --- a/level.h +++ b/level.h @@ -12,5 +12,6 @@ const Block BLOCK_WALL01; Block get_block(GLushort x, GLushort y); void set_image(TGAimage* image); +const struct aiScene* import_model(const char* path); #endif -- 2.44.0