diff options
author | omnisci3nce <omniscient.oce@gmail.com> | 2024-07-12 12:47:07 +1000 |
---|---|---|
committer | omnisci3nce <omniscient.oce@gmail.com> | 2024-07-12 12:47:07 +1000 |
commit | f74cf52946f4e569a26bc81105537b40be95c2c7 (patch) | |
tree | 1d000367350d0e28eb7cfbc800286a0ed30a4e6c /src/systems | |
parent | fedba7ff68924ff50022405fc9103a5acf7013fe (diff) |
wip: big makeover
Diffstat (limited to 'src/systems')
-rw-r--r-- | src/systems/input.c | 12 | ||||
-rw-r--r-- | src/systems/input.h | 6 | ||||
-rw-r--r-- | src/systems/terrain.c | 15 | ||||
-rw-r--r-- | src/systems/terrain.h | 8 | ||||
-rw-r--r-- | src/systems/text.h | 82 |
5 files changed, 58 insertions, 65 deletions
diff --git a/src/systems/input.c b/src/systems/input.c index 0c8f768..a371ecd 100644 --- a/src/systems/input.c +++ b/src/systems/input.c @@ -6,11 +6,11 @@ #include "log.h" -static input_state *g_input; // Use a global to simplify caller code +static Input_State *g_input; // Use a global to simplify caller code -bool input_system_init(input_state *input, GLFWwindow *window) { +bool Input_Init(Input_State *input, GLFWwindow *window) { INFO("Input init"); - memset(input, 0, sizeof(input_state)); + memset(input, 0, sizeof(Input_State)); input->window = window; // Set everything to false. Could just set memory to zero but where's the fun in that @@ -29,9 +29,9 @@ bool input_system_init(input_state *input, GLFWwindow *window) { return true; } -void input_system_shutdown(input_state *input) {} +void Input_Shutdown(Input_State *input) {} -void input_update(input_state *input) { +void Input_Update(Input_State *input) { glfwPollEvents(); // --- update keyboard input @@ -95,4 +95,4 @@ bool key_is_pressed(keycode key) { return g_input->depressed_keys[key]; } bool key_just_pressed(keycode key) { return g_input->just_pressed_keys[key]; } -bool key_just_released(keycode key) { return g_input->just_released_keys[key]; }
\ No newline at end of file +bool key_just_released(keycode key) { return g_input->just_released_keys[key]; } diff --git a/src/systems/input.h b/src/systems/input.h index 1ef7940..11c40ea 100644 --- a/src/systems/input.h +++ b/src/systems/input.h @@ -36,7 +36,7 @@ bool key_just_released(keycode key); // --- Lifecycle -bool Input_Init(Input_state *input, struct GLFWwindow *window); -void Input_Shutdown(Input_state *input); +bool Input_Init(Input_State *input, struct GLFWwindow *window); +void Input_Shutdown(Input_State *input); -void Input_Update(Input_state *state); // must be run once per main loop +void Input_Update(Input_State *state); // must be run once per main loop diff --git a/src/systems/terrain.c b/src/systems/terrain.c index a8e8b48..1d23cc3 100644 --- a/src/systems/terrain.c +++ b/src/systems/terrain.c @@ -1,30 +1,19 @@ /** - * @file terrain.c - * @author your name (you@domain.com) * @brief - * @version 0.1 - * @date 2024-06-22 - * - * @copyright Copyright (c) 2024 - * */ #include "terrain.h" #include "ral.h" struct Terrain_Storage { arena terrain_allocator; - heightmap* heightmap; // NULL = no heightmap + Heightmap* heightmap; // NULL = no heightmap GPU_Renderpass* hmap_renderpass; GPU_Pipeline* hmap_pipeline; }; -PUB bool Terrain_Init(Terrain_Storage* storage) { - - return true; -} +PUB bool Terrain_Init(Terrain_Storage* storage) { return true; } PUB void Terrain_Shutdown(Terrain_Storage* storage); - /* bool terrain_system_init(terrain_state* state) { */ /* gpu_renderpass_desc rpass_desc = { */ /* .default_framebuffer = true, */ diff --git a/src/systems/terrain.h b/src/systems/terrain.h index a65ecec..890cb90 100644 --- a/src/systems/terrain.h +++ b/src/systems/terrain.h @@ -19,7 +19,7 @@ Future: #include "str.h" typedef struct Heightmap { - str8 filepath; + Str8 filepath; u32x2 size; void* image_data; bool is_uploaded; @@ -32,9 +32,13 @@ PUB bool Terrain_Init(Terrain_Storage* storage); PUB void Terrain_Shutdown(Terrain_Storage* storage); PUB void Terrain_Run(Terrain_Storage* storage); // NOTE: For now it renders directly to main framebuffer -PUB Heightmap Heightmap_FromImage(str8 filepath); +/** @brief Sets the active heightmap to be rendered and collided against. */ +PUB Heightmap Terrain_LoadHeightmap(Heightmap hmap, bool free_on_upload); +PUB Heightmap Heightmap_FromImage(Str8 filepath); PUB Heightmap Heightmap_FromPerlin(/* TODO: perlin noise generation parameters */); +PUB bool Terrain_IsActive(); // checks whether we have a loaded heightmap and it's being rendered + // --- Internal // TODO: void terrain_system_render_hmap(renderer* rend, terrain_state* state); diff --git a/src/systems/text.h b/src/systems/text.h index f40cfd6..983ffd6 100644 --- a/src/systems/text.h +++ b/src/systems/text.h @@ -10,44 +10,44 @@ #include "ral.h" #include "render_types.h" -struct core; - -/** @brief internal font struct */ -typedef struct font { - const char *name; - stbtt_fontinfo stbtt_font; - stbtt_bakedchar c_data[96]; - texture_handle bitmap_tex; -} font; - -typedef struct draw_text_packet { - char *contents; - f32 x; - f32 y; -} draw_text_packet; - -KITC_DECL_TYPED_ARRAY(draw_text_packet) - -typedef struct text_system_state { - font default_font; - shader_handle glyph_shader; - u32 glyph_vbo; - u32 glyph_vao; - draw_text_packet_darray *draw_cmd_buf; - // TODO: fonts array or hashtable -} text_system_state; - -void text_system_render(text_system_state *text); - -// --- Lifecycle functions -bool text_system_init(text_system_state *text); -void text_system_shutdown(text_system_state *text); - -// --- Drawing - -/** - * @brief immediate mode draw text. - * @note immediately emits draw calls causing a shader program switch if you weren't previously - drawing text in the current frame. -*/ -void draw_text(struct core *core, f32 x, f32 y, char *contents);
\ No newline at end of file +// struct core; + +// /** @brief internal font struct */ +// typedef struct font { +// const char *name; +// stbtt_fontinfo stbtt_font; +// stbtt_bakedchar c_data[96]; +// texture_handle bitmap_tex; +// } font; + +// typedef struct draw_text_packet { +// char *contents; +// f32 x; +// f32 y; +// } draw_text_packet; + +// KITC_DECL_TYPED_ARRAY(draw_text_packet) + +// typedef struct text_system_state { +// font default_font; +// shader_handle glyph_shader; +// u32 glyph_vbo; +// u32 glyph_vao; +// draw_text_packet_darray *draw_cmd_buf; +// // TODO: fonts array or hashtable +// } text_system_state; + +// void text_system_render(text_system_state *text); + +// // --- Lifecycle functions +// bool text_system_init(text_system_state *text); +// void text_system_shutdown(text_system_state *text); + +// // --- Drawing + +// /** +// * @brief immediate mode draw text. +// * @note immediately emits draw calls causing a shader program switch if you weren't previously +// drawing text in the current frame. +// */ +// void draw_text(struct core *core, f32 x, f32 y, char *contents); |