]> git.lizzy.rs Git - shadowclad.git/commitdiff
Link libassimp and test importing a 3ds file
authoroutfrost <kotlet.bahn@gmail.com>
Thu, 11 Oct 2018 00:19:15 +0000 (02:19 +0200)
committeroutfrost <kotlet.bahn@gmail.com>
Thu, 11 Oct 2018 00:19:15 +0000 (02:19 +0200)
Makefile
level.c
level.h
main.c

index 2e38020f24e1c14170cbeed3480b78e17fd97c45..f6af9aad28583e9302a5dd0afc012f11678bdb65 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 compileargs = -Wall -Wextra -Wpedantic
-linkargs = -lGL -lglut
+linkargs = -L/usr/local/lib -lGL -lglut -lassimp
 objects = out/main.o out/debugutil.o out/glut_janitor.o out/render.o \
           out/tga.o out/level.o
 
@@ -7,7 +7,7 @@ shadowclad : $(objects)
        gcc -o out/shadowclad $(objects) $(linkargs)
 
 run : shadowclad
-       out/shadowclad
+       LD_LIBRARY_PATH=/usr/local/lib out/shadowclad
 
 out/main.o : main.c debugutil.h glut_janitor.h render.h
        gcc -c -o out/main.o main.c $(compileargs)
diff --git a/level.c b/level.c
index 096964670b5ba393e1ef0fc97f569b24d2bb3ba0..9f9b240ba628721d2d8cb98860933efd53e8b095 100644 (file)
--- a/level.c
+++ b/level.c
@@ -1,9 +1,15 @@
 #include <GL/gl.h>
 #include <stdlib.h>
+#include <stdio.h> // TODO remove
+#include <assimp/cimport.h>
+#include <assimp/scene.h>
 
 #include "level.h"
 #include "tga.h"
 
+const Block BLOCK_EMPTY = 0;
+const Block BLOCK_WALL01 = 1;
+
 TGAimage* level_image = NULL;
 
 Block get_block(GLushort x, GLushort y) {
@@ -16,3 +22,25 @@ Block get_block(GLushort x, GLushort y) {
 void set_image(TGAimage* image) {
        level_image = image;
 }
+
+void import_model(const char* path) {
+       const struct aiScene* scene = aiImportFile(path, 0u);
+       if (scene == NULL) {
+               printf("We have nothing.\n");
+               return;
+       }
+       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);
+}
diff --git a/level.h b/level.h
index 692f01de9cf69eb8255744f08ccfd7914ceb73ae..84d2c6a29553fc19311436f7d6946db9994f27fc 100644 (file)
--- a/level.h
+++ b/level.h
@@ -7,8 +7,8 @@
 
 typedef GLuint Block;
 
-const Block BLOCK_EMPTY = 0;
-const Block BLOCK_WALL01 = 1;
+const Block BLOCK_EMPTY;
+const Block BLOCK_WALL01;
 
 Block get_block(GLushort x, GLushort y);
 void set_image(TGAimage* image);
diff --git a/main.c b/main.c
index 7bca0aa32e8357ca1dea04b74c12947bf404a0fa..cec65b9fef048f4a0603432c7841a9bddd1c0876 100644 (file)
--- a/main.c
+++ b/main.c
@@ -3,6 +3,7 @@
 #include "debugutil.h"
 #include "glut_janitor.h"
 #include "render.h"
+#include "level.h"
 
 int main(int argc, char** argv) {
        glutInit(&argc, argv);
@@ -22,6 +23,8 @@ int main(int argc, char** argv) {
        
        init_render();
        
+       import_model("out/assets/wall01.3ds");
+       
        glutMainLoop();
        return 0;
 }