From 4b410af18ed7e76b42be1d2ab2ebdfe8e5bf97e8 Mon Sep 17 00:00:00 2001 From: realtradam Date: Wed, 8 Mar 2023 00:19:55 -0500 Subject: Continued cleanup and refactoring. Added string type. --- include/rodeo.h | 106 +++++++++++++++++++++++++++++-------------------- include/rodeo_config.h | 4 +- include/rodeo_math.h | 11 ----- include/rodeo_types.h | 33 ++++++++------- 4 files changed, 82 insertions(+), 72 deletions(-) delete mode 100644 include/rodeo_math.h (limited to 'include') diff --git a/include/rodeo.h b/include/rodeo.h index 713e260..bd156cb 100644 --- a/include/rodeo.h +++ b/include/rodeo.h @@ -5,6 +5,7 @@ // system #include #include +#include #include #include @@ -16,95 +17,114 @@ !mrodeo_macrovar(_macrovar_); \ (mrodeo_macrovar(_macrovar_) += 1), end) \ +/// --- Math --- + +uint32_t +rodeo_rgba_to_uint32(const rodeo_rgba_t color); + +/// --- Core --- + #define \ mrodeo_window_do( \ - state, \ screen_height, \ screen_width, \ title \ ) \ mrodeo_defer_do( \ rodeo_window_init( \ - &state, \ screen_height, \ screen_width, \ title \ ), \ - rodeo_window_deinit(state) \ + rodeo_window_deinit() \ ) void -rodeo_\ -window_init( - rodeo_data_p *state, +rodeo_window_init( int screen_height, int screen_width, char* title ); void -rodeo_\ -window_deinit(rodeo_data_p state); - -void -rodeo_\ -deinit(void); +rodeo_window_deinit(void); #define \ -mrodeo_do( \ +mrodeo_frame_do( \ state \ ) \ mrodeo_defer_do( \ - rodeo_begin(state), \ - rodeo_end(state) \ + rodeo_frame_begin(state), \ + rodeo_frame_end(state) \ ) void -rodeo_\ -begin(rodeo_data_p state); +rodeo_frame_begin(void); void -rodeo_\ -end(rodeo_data_p state); +rodeo_frame_end(void); void -rodeo_\ -mainloop_set( - rodeo_data_p state, +rodeo_mainloop_run( rodeo_mainloop_func main_loop_function ); bool -rodeo_\ -window_check_quit(rodeo_data_p state); +rodeo_window_check_quit(void); void -rodeo_\ -set_quit(rodeo_data_p state, bool quit); +rodeo_set_quit(bool quit); void -rodeo_\ -debug_text_draw(uint16_t x, uint16_t y, const char *format, ...); +rodeo_debug_text_draw(uint16_t x, uint16_t y, const char *format, ...); -// rodeo_renderer_name_get -const char * -rodeo_\ -renderer_name_get(void); +rodeo_string_p +rodeo_renderer_name_get(void); -// rodeo_renderer_flush void -rodeo_\ -renderer_flush(rodeo_data_p state); +rodeo_renderer_flush(void); -// rodeo_rectangle_draw void -rodeo_\ -rectangle_draw( - rodeo_data_p state, - uint16_t x, - uint16_t y, - uint16_t width, - uint16_t height, +rodeo_rectangle_draw( + rodeo_rectangle_t rectangle, rodeo_rgba_t color ); +/// --- String --- + +rodeo_string_p +rodeo_string_create(const char *c_string); + +void +rodeo_string_destroy(rodeo_string_p self); + +char* +rodeo_string_to_cstr(rodeo_string_p self); + +const char* +rodeo_string_to_constcstr(rodeo_string_p self); + +void +rodeo_string_insert( + rodeo_string_p self, + const rodeo_string_p insert, + intptr_t position +); + +void +rodeo_string_append( + rodeo_string_p self, + const rodeo_string_p append +); + +void +rodeo_string_prepend( + rodeo_string_p self, + const rodeo_string_p prepend +); + +void +rodeo_string_clear(rodeo_string_p self); + +void +rodeo_string_set(rodeo_string_p self, char* value); diff --git a/include/rodeo_config.h b/include/rodeo_config.h index 55bf057..247a0b2 100644 --- a/include/rodeo_config.h +++ b/include/rodeo_config.h @@ -1,2 +1,4 @@ -#define RODEO__MAX_VERTEX_SIZE 8192 +#ifndef mrodeo_vertex_size_max + #define mrodeo_vertex_size_max 8192 +#endif diff --git a/include/rodeo_math.h b/include/rodeo_math.h deleted file mode 100644 index 4dee9ae..0000000 --- a/include/rodeo_math.h +++ /dev/null @@ -1,11 +0,0 @@ - -// public internal -#include "rodeo_types.h" - -// system -#include "stdint.h" - -uint32_t -Rodeo__\ -Math__\ -color_rgba_to_uint32(const rodeo_rgba_t color); diff --git a/include/rodeo_types.h b/include/rodeo_types.h index e35c482..bdd7ab7 100644 --- a/include/rodeo_types.h +++ b/include/rodeo_types.h @@ -4,36 +4,35 @@ #include #include -typedef -struct +typedef struct { float red; float green; float blue; float alpha; } -rodeo_\ -rgba_t; +rodeo_rgba_t; -typedef -struct +typedef struct { float x; float y; float z; uint32_t abgr; } -rodeo_\ -position_color_vertex_t; -//rodeo_poscolvert_t - -typedef -struct -rodeo_data_t -*rodeo_data_p; +rodeo_vertex_t; typedef void -(*rodeo_\ -mainloop_func) -(void); +(*rodeo_mainloop_func)(void); + +typedef struct +{ + float x; + float y; + float width; + float height; +} +rodeo_rectangle_t; + +typedef union rodeo_string_t *rodeo_string_p; -- cgit v1.2.3