From a5a82709028c475d0ff6cd54f6d07f16375e156e Mon Sep 17 00:00:00 2001 From: gramanas Date: Fri, 31 May 2024 21:00:57 +0300 Subject: Allaboard --- src/state.h | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/state.h') diff --git a/src/state.h b/src/state.h index b56544a..c7b567f 100644 --- a/src/state.h +++ b/src/state.h @@ -27,6 +27,8 @@ typedef struct { mat4 view; mat4 proj; vec2 resolution; + float time; + float dt; } UniformBufferObject; typedef struct { @@ -43,6 +45,23 @@ typedef struct { VkDescriptorSet vk_descriptor_set; } frame_data; +typedef struct { + float x; + float y; +} V2; + +typedef struct { + float x; + float y; + float z; +} V3; + +typedef struct { + V3 pos; + V3 color; + V2 texCoord; +} Vertex; + typedef struct state { camera3d camera; @@ -54,6 +73,7 @@ typedef struct state { int rotate; int mouse_pressed; + int middle_click; UniformBufferObject ubo; @@ -102,6 +122,7 @@ typedef struct state { shaderc_compilation_result_t prev_vert_result; shaderc_compilation_result_t prev_frag_result; + uint32_t vk_mip_levels; VkImage vk_texture_image; VkDeviceMemory vk_texture_image_memory; VkImageView vk_texture_image_view; @@ -112,11 +133,22 @@ typedef struct state { VkImageView vk_depth_image_view; VkPolygonMode polygon_mode; -} state_t ; + + Vertex *vertices; + size_t vertices_count; + uint32_t * indices; + size_t indices_count; + VkBuffer vertexBuffer; + VkDeviceMemory vertexBufferMemory; + + char model_path[1000]; +} state_t; static void -init_state(state_t * s) +init_state(state_t *s) { + + strcpy(s->model_path, "assets/viking_room.obj"); s->camera.pos[0] = 2.0f; s->camera.pos[1] = 2.0f; s->camera.pos[2] = 2.0f; @@ -137,6 +169,7 @@ init_state(state_t * s) s->rotate = 0; s->mouse_pressed = 0; + s->middle_click = 0; s->sdl_window_resized = 0; @@ -154,6 +187,8 @@ init_state(state_t * s) s->zoom = 10; s->x = 0.0f; + glm_mat4_identity(s->ubo.model); + s->sdl_window = NULL; s->vk_swap_chain_image_count = 0; -- cgit v1.2.3