From 626e12e649680a8b4f5ddf64898ecdb72862ec62 Mon Sep 17 00:00:00 2001 From: outfrost Date: Thu, 11 Oct 2018 02:19:15 +0200 Subject: [PATCH] Link libassimp and test importing a 3ds file --- Makefile | 4 ++-- level.c | 28 ++++++++++++++++++++++++++++ level.h | 4 ++-- main.c | 3 +++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2e38020..f6af9aa 100644 --- 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 0969646..9f9b240 100644 --- a/level.c +++ b/level.c @@ -1,9 +1,15 @@ #include #include +#include // TODO remove +#include +#include #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 692f01d..84d2c6a 100644 --- 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 7bca0aa..cec65b9 100644 --- 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; } -- 2.44.0