]> git.lizzy.rs Git - shadowclad.git/commitdiff
Return aiScene* from import, move prints to debugutil
authoroutfrost <kotlet.bahn@gmail.com>
Mon, 5 Nov 2018 02:11:35 +0000 (03:11 +0100)
committeroutfrost <kotlet.bahn@gmail.com>
Mon, 5 Nov 2018 02:11:35 +0000 (03:11 +0100)
debugutil.c
debugutil.h
level.c
level.h

index 143c73802bd0c287830d3c2ed0757629be6127dd..cd911b94e7bae26c28dcfe1644509c7091d0dff9 100644 (file)
@@ -2,6 +2,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <assimp/scene.h>
 
 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);
+}
index f2b4e695f3a99e8fdc79595a7a2ed51fefa80a93..2d7793b879a2c11b39c8b3c49ce88d3691f4c82a 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef DEBUGUTIL_H_
 #define DEBUGUTIL_H_
 
+#include <stdio.h>
+#include <assimp/scene.h>
+
 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 9f9b240ba628721d2d8cb98860933efd53e8b095..2c9dba2fc03dc7c43c253f5a4b3dcc805ca00a9e 100644 (file)
--- 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 84d2c6a29553fc19311436f7d6946db9994f27fc..fe274949add4ffc2b5e31d26ca40c1ba56c92fc5 100644 (file)
--- 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