diff options
| author | realtradam <[email protected]> | 2023-03-05 06:38:09 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-03-05 06:38:09 -0500 |
| commit | e58d0577634b1405a40a4b1ebd0a36323fa81970 (patch) | |
| tree | e0facd0d5e396b07ef161dc7ef885c71694d0cbb /src | |
| parent | eb6a382d03c5b9c915a949ea1119c2cbf72f1d6e (diff) | |
| download | RodeoKit-e58d0577634b1405a40a4b1ebd0a36323fa81970.tar.gz RodeoKit-e58d0577634b1405a40a4b1ebd0a36323fa81970.zip | |
initial rewrite to follow new styleguide
Diffstat (limited to 'src')
| -rw-r--r-- | src/compile_flags.txt | 3 | ||||
| -rw-r--r-- | src/private/rodeo_internal.h | 4 | ||||
| -rw-r--r-- | src/private/rodeo_internal_types.h | 7 | ||||
| -rw-r--r-- | src/rodeo.c | 98 | ||||
| -rw-r--r-- | src/rodeo_error.c | 2 | ||||
| -rw-r--r-- | src/rodeo_math.c | 2 | ||||
| -rw-r--r-- | src/rodeo_types.c | 8 |
7 files changed, 63 insertions, 61 deletions
diff --git a/src/compile_flags.txt b/src/compile_flags.txt index 0d92969..2cccc56 100644 --- a/src/compile_flags.txt +++ b/src/compile_flags.txt @@ -4,3 +4,6 @@ -I../external/bgfx/include -I../external/bx/include -I../external/cglm/include +-Wall +-Wextra +-Wpedantic diff --git a/src/private/rodeo_internal.h b/src/private/rodeo_internal.h index f01ac87..0773f12 100644 --- a/src/private/rodeo_internal.h +++ b/src/private/rodeo_internal.h @@ -3,5 +3,5 @@ #include "private/rodeo_internal_types.h" bgfx_shader_handle_t -_Rodeo__\ -load_shader(const char* path); +irodeo_\ +shader_load(const char* path); diff --git a/src/private/rodeo_internal_types.h b/src/private/rodeo_internal_types.h index 2114942..20b8c43 100644 --- a/src/private/rodeo_internal_types.h +++ b/src/private/rodeo_internal_types.h @@ -13,8 +13,7 @@ #include "bgfx/c99/bgfx.h" struct -Rodeo__\ -data +rodeo_data_t { SDL_Window* window; SDL_Surface* screen_surface; @@ -28,11 +27,11 @@ data bgfx_dynamic_vertex_buffer_handle_t vertex_buffer_handle; bgfx_dynamic_index_buffer_handle_t index_buffer_handle; uint16_t vertex_size; - Rodeo__position_color_vertex_t batched_vertices[RODEO__MAX_VERTEX_SIZE]; + rodeo_position_color_vertex_t batched_vertices[RODEO__MAX_VERTEX_SIZE]; uint16_t index_count; uint16_t index_size; uint16_t batched_indices[(RODEO__MAX_VERTEX_SIZE / 4) * 6]; bgfx_shader_handle_t vertex_shader; bgfx_shader_handle_t fragment_shader; bgfx_program_handle_t program_shader; -} Rodeo__data_t; +} rodeo_data_t; diff --git a/src/rodeo.c b/src/rodeo.c index 3a60b92..10654ac 100644 --- a/src/rodeo.c +++ b/src/rodeo.c @@ -1,4 +1,4 @@ - +// -- internal -- // public internal #include "rodeo.h" #include "rodeo_math.h" @@ -8,7 +8,7 @@ #include "private/rodeo_internal_types.h" #include "private/rodeo_error.h" -// external +// -- external -- #if __EMSCRIPTEN__ #include <emscripten/emscripten.h> #endif @@ -21,21 +21,21 @@ #include "cglm/cglm.h" void -Rodeo__\ -init_window( - Rodeo__data_p *state_p, +rodeo_\ +window_init( + rodeo_data_p *state_p, int screen_height, int screen_width, char* title ) { - *state_p = (Rodeo__data_p)malloc(sizeof(Rodeo__data_t)); - Rodeo__data_p state = *state_p; + *state_p = (rodeo_data_p)malloc(sizeof(rodeo_data_t)); + rodeo_data_p state = *state_p; if(!state) { Rodeo__error_exit( RODEO__ERROR__UNINITIALIZED_STATE, - __FUNCTION__, + __func__, __LINE__, "Malloc failed to initialize state." ); @@ -161,8 +161,8 @@ init_window( fragment_path[shader_length + fragment_length] = 0; vertex_path[shader_length + vertex_length] = 0; - state->vertex_shader = _Rodeo__load_shader(vertex_path); - state->fragment_shader = _Rodeo__load_shader(fragment_path); + state->vertex_shader = irodeo_shader_load(vertex_path); + state->fragment_shader = irodeo_shader_load(fragment_path); state->program_shader = bgfx_create_program( state->vertex_shader, state->fragment_shader, @@ -171,14 +171,14 @@ init_window( } void -Rodeo__\ -deinit_window(Rodeo__data_p state) +rodeo_\ +window_deinit(rodeo_data_p state) { if(!state) { Rodeo__error_exit( RODEO__ERROR__UNINITIALIZED_STATE, - __FUNCTION__, + __func__, __LINE__, RODEO__EMPTY_ERROR_MESSAGE ); @@ -191,21 +191,21 @@ deinit_window(Rodeo__data_p state) } void -Rodeo__\ -quit() +rodeo_\ +deinit(void) { SDL_Quit(); } void -Rodeo__\ -begin(Rodeo__data_p state) +rodeo_\ +begin(rodeo_data_p state) { if(!state) { Rodeo__error_exit( RODEO__ERROR__UNINITIALIZED_STATE, - __FUNCTION__, + __func__, __LINE__, RODEO__EMPTY_ERROR_MESSAGE ); @@ -239,19 +239,19 @@ begin(Rodeo__data_p state) } void -Rodeo__\ -end(Rodeo__data_p state) +rodeo_\ +end(rodeo_data_p state) { if(!state) { Rodeo__error_exit( RODEO__ERROR__UNINITIALIZED_STATE, - __FUNCTION__, + __func__, __LINE__, RODEO__EMPTY_ERROR_MESSAGE ); } - Rodeo__flush_batch(state); + rodeo_renderer_flush(state); bgfx_frame(false); @@ -265,16 +265,16 @@ end(Rodeo__data_p state) } void -Rodeo__\ -execute_main_loop( - Rodeo__data_p state, - Rodeo__main_loop_p main_loop_function +rodeo_\ +mainloop_set( + rodeo_data_p state, + rodeo_mainloop_func main_loop_function ) { #if __EMSCRIPTEN__ emscripten_set_main_loop(main_loop_function, 0, 1); #else - while(!Rodeo__should_quit(state)) + while(!rodeo_window_check_quit(state)) { main_loop_function(); } @@ -282,22 +282,22 @@ execute_main_loop( } bool -Rodeo__\ -should_quit(Rodeo__data_p state) +rodeo_\ +window_check_quit(rodeo_data_p state) { return state->quit; } void -Rodeo__\ -set_quit(Rodeo__data_p state, bool quit) +rodeo_\ +set_quit(rodeo_data_p state, bool quit) { state->quit = quit; } void -Rodeo__\ -draw_debug_text(u_int16_t x, u_int16_t y, const char *format, ...) +rodeo_\ +debug_text_draw(u_int16_t x, u_int16_t y, const char *format, ...) { va_list argList; va_start(argList, format); @@ -306,21 +306,21 @@ draw_debug_text(u_int16_t x, u_int16_t y, const char *format, ...) } const char * -Rodeo__\ -get_renderer_name_as_string() +rodeo_\ +renderer_name_get(void) { return bgfx_get_renderer_name(bgfx_get_renderer_type()); } void -Rodeo__\ -flush_batch(Rodeo__data_p state) +rodeo_\ +renderer_flush(rodeo_data_p state) { if(state->vertex_size > 0) { // upload remaining batched vertices bgfx_set_dynamic_vertex_buffer(0, state->vertex_buffer_handle, 0, state->vertex_size); - const bgfx_memory_t* vbm = bgfx_copy(state->batched_vertices, sizeof(Rodeo__position_color_vertex_t) * state->vertex_size); + const bgfx_memory_t* vbm = bgfx_copy(state->batched_vertices, sizeof(rodeo_position_color_vertex_t) * state->vertex_size); bgfx_update_dynamic_vertex_buffer(state->vertex_buffer_handle, 0, vbm); // upload remaining batched indices @@ -349,39 +349,39 @@ flush_batch(Rodeo__data_p state) } void -Rodeo__\ -draw_rectangle( - Rodeo__data_p state, +rodeo_\ +rectangle_draw( + rodeo_data_p state, u_int16_t x, u_int16_t y, u_int16_t width, u_int16_t height, - Rodeo__color_rgba_t color + rodeo_rgba_t color ) { const uint32_t abgr = Rodeo__Math__color_rgba_to_uint32(color); if(state->vertex_size < RODEO__MAX_VERTEX_SIZE) { state->batched_vertices[state->vertex_size] = - (Rodeo__position_color_vertex_t) + (rodeo_position_color_vertex_t) { (float)width + (float)x, (float)height + (float)y, 0.0f, abgr }; state->vertex_size += 1; state->batched_vertices[state->vertex_size] = - (Rodeo__position_color_vertex_t) + (rodeo_position_color_vertex_t) { (float)width + (float)x, (float)y, 0.0f, abgr }; state->vertex_size += 1; state->batched_vertices[state->vertex_size] = - (Rodeo__position_color_vertex_t) + (rodeo_position_color_vertex_t) { (float)x, (float)y, 0.0f, abgr }; state->vertex_size += 1; state->batched_vertices[state->vertex_size] = - (Rodeo__position_color_vertex_t) + (rodeo_position_color_vertex_t) { (float)x, (float)height + (float)y, 0.0f, abgr }; @@ -411,13 +411,13 @@ draw_rectangle( if(state->vertex_size >= RODEO__MAX_VERTEX_SIZE) { - Rodeo__flush_batch(state); + rodeo_renderer_flush(state); } } bgfx_shader_handle_t -_Rodeo__\ -load_shader(const char* path) +irodeo_\ +shader_load(const char* path) { bgfx_shader_handle_t invalid = BGFX_INVALID_HANDLE; diff --git a/src/rodeo_error.c b/src/rodeo_error.c index 1b5b03d..4190883 100644 --- a/src/rodeo_error.c +++ b/src/rodeo_error.c @@ -38,7 +38,7 @@ error_exit( default: Rodeo__error_exit( RODEO__ERROR__UNREACHABLE_REACHED, - __FUNCTION__, + __func__, __LINE__, "Unhandled error code." ); diff --git a/src/rodeo_math.c b/src/rodeo_math.c index 248e600..f45c6e6 100644 --- a/src/rodeo_math.c +++ b/src/rodeo_math.c @@ -6,7 +6,7 @@ uint32_t Rodeo__\ Math__\ -color_rgba_to_uint32(const Rodeo__color_rgba_t color) +color_rgba_to_uint32(const rodeo_rgba_t color) { return ((uint32_t)(uint8_t)(color.red * 255)) diff --git a/src/rodeo_types.c b/src/rodeo_types.c index ff87e27..f7e5285 100644 --- a/src/rodeo_types.c +++ b/src/rodeo_types.c @@ -12,8 +12,6 @@ #include "bgfx/c99/bgfx.h" struct -Rodeo__\ -data_t { SDL_Window* window; SDL_Surface* screen_surface; @@ -27,11 +25,13 @@ data_t bgfx_dynamic_vertex_buffer_handle_t vertex_buffer_handle; bgfx_dynamic_index_buffer_handle_t index_buffer_handle; uint16_t vertex_size; - Rodeo__position_color_vertex_t batched_vertices[RODEO__MAX_VERTEX_SIZE]; + rodeo_position_color_vertex_t batched_vertices[RODEO__MAX_VERTEX_SIZE]; uint16_t index_count; uint16_t index_size; uint16_t batched_indices[(RODEO__MAX_VERTEX_SIZE / 4) * 6]; bgfx_shader_handle_t vertex_shader; bgfx_shader_handle_t fragment_shader; bgfx_program_handle_t program_shader; -}; +} +rodeo_\ +data_t; |
