From e1935b6f7af6d036eb15c75c2a98bf43805c48fc Mon Sep 17 00:00:00 2001 From: sanine-a Date: Mon, 1 Jun 2020 22:33:43 -0500 Subject: add model loading --- demo.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'demo.c') diff --git a/demo.c b/demo.c index 8f5b7c9..f3423d9 100644 --- a/demo.c +++ b/demo.c @@ -23,6 +23,10 @@ vec3 light_position = { 2, 2, 2 }; mat4 light_model; honey_shader light_shader; +honey_model suzanne; +mat4 suzanne_model; +honey_texture suzanne_tex; + bool wireframe = false; /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -126,10 +130,11 @@ void draw() { honey_shader_set_mat4(light_shader, "view", camera.view); honey_shader_set_mat4(light_shader, "model", light_model); - honey_texture_use(container, 0); + honey_texture_use(suzanne_tex, 0); honey_texture_use(happy_face, 1); - honey_mesh_draw(cube, cube_shader); + //honey_mesh_draw(cube, cube_shader); + honey_model_draw(&suzanne, cube_shader); honey_mesh_draw(light_cube, light_shader); glfwSwapBuffers(window); @@ -154,6 +159,8 @@ int main() { if (honey_texture_new(&happy_face, "happy.png", true) != TEXTURE_OK) { return 1; } + + honey_texture_new(&suzanne_tex, "Suzanne-tex.png", true); honey_error result = honey_shader_load(&cube_shader, "demo.vs", "demo.fs"); if (result != HONEY_OK) { @@ -176,6 +183,14 @@ int main() { return 1; } + result = honey_model_load(&suzanne, "Suzanne.obj"); + if (result != HONEY_OK) { + char error_message[3*HONEY_ERROR_DATA_STRING_LENGTH]; + honey_human_readable_error(error_message, result); + fprintf(stderr, "%s\n", error_message); + return 1; + } + glm_mat4_identity(light_model); glm_translate(light_model, light_position); @@ -227,6 +242,7 @@ int main() { honey_run(window); honey_mesh_delete(cube); + honey_model_delete(&suzanne); honey_shader_delete(cube_shader); honey_quit(); -- cgit v1.2.1