diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-11-25 15:35:01 +0200 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-11-25 15:35:01 +0200 |
commit | 4323e172facadb0af33c3295e019fcd5d8547ca5 (patch) | |
tree | c0ec9a440c6a34edc8300fc870f69cb5c7b7a617 /src/main.c | |
parent | 1e436946514f3a0e9fe3d091394db6b86e06f033 (diff) |
depth image lets gooo
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -1,12 +1,14 @@ #include <stdio.h> #include <stdlib.h> #include <sys/times.h> + +#define CGLM_FORCE_DEPTH_ZERO_TO_ONE #include <cglm/cglm.h> #include <cglm/struct.h> #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); |