From 4323e172facadb0af33c3295e019fcd5d8547ca5 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sat, 25 Nov 2023 15:35:01 +0200 Subject: depth image lets gooo --- src/main.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index edaf8a3..6cd0252 100644 --- a/src/main.c +++ b/src/main.c @@ -1,12 +1,14 @@ #include #include #include + +#define CGLM_FORCE_DEPTH_ZERO_TO_ONE #include #include #include "objload.h" - #define MONKEY + #include "graphics.h" #include "window.h" #include "common.h" @@ -30,15 +32,21 @@ struct ubo { vertex_t vertices[] = { {{-0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}}, - {{ 0.5f, -0.5f, -0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}}, + {{ 0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}}, {{ 0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}}, + {{-0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}}, + + {{-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}}, + {{ 0.5f, -0.5f, -0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}}, + {{ 0.5f, 0.5f, -0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}}, {{-0.5f, 0.5f, -0.5f}, {0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}}, }; #endif u32 indices[] = { - 0, 1, 2, 2, 3, 0 + 0, 1, 2, 2, 3, 0, + 4, 5, 6, 6, 7, 4, }; @@ -84,7 +92,6 @@ int main(void) }; obj_transfer_raw(obj, obj_metadata, &nvertices, NULL); - // leaks memory objvertices = xcalloc(nvertices, sizeof(*objvertices)); obj_transfer_raw(obj, obj_metadata, &nvertices, objvertices); @@ -141,11 +148,19 @@ int main(void) running = 0; break; } - - graphics_draw_frame(graphics); + + #ifndef MONKEY + graphics_draw_frame(graphics, grph_info.nindices); + #else + graphics_draw_frame(graphics, grph_info.nvertices); + #endif } ret = 0; + +#ifdef MONKEY + free(objvertices); +#endif graphics_destroy(graphics); f3: window_destroy(window); @@ -164,7 +179,7 @@ int update_ubo(void *uniform_buffer) glm_rotate(ubo->model, time * glm_rad(90.0f), (vec3){0.0f, 0.0f, 1.0f}); - glm_lookat((vec3){2.0f, 2.0f, 2.0f}, (vec3){0.0f, 0.0f, 0.0f}, (vec3){0.0f, 0.0f, 1.0f}, ubo->view); + glm_lookat((vec3){2.0f, 2.0f, 0.0f}, (vec3){0.0f, 0.0f, 0.0f}, (vec3){0.0f, 0.0f, 1.0f}, ubo->view); glm_perspective(glm_rad(45.0f), (float)width/(float)height, 0.1f, 10.0f, ubo->proj); -- cgit v1.2.3