diff options
| author | realtradam <[email protected]> | 2023-06-04 02:35:00 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-06-04 02:35:00 -0400 |
| commit | 35558b39040d37c939bd68b56985d6cb5385a451 (patch) | |
| tree | b10516557ba530d96799a8c4bed94b7644938811 /include/rodeo | |
| parent | 856ce67eb21f64d86ecf6bb3651985f10e6236c3 (diff) | |
| download | RodeoKit-gfx-rewrite.tar.gz RodeoKit-gfx-rewrite.zip | |
refactor to have graphics and windowing seperategfx-rewrite
Diffstat (limited to 'include/rodeo')
| -rw-r--r-- | include/rodeo/audio.h | 15 | ||||
| -rw-r--r-- | include/rodeo/gfx.h | 98 | ||||
| -rw-r--r-- | include/rodeo/gfx_t.h | 66 | ||||
| -rw-r--r-- | include/rodeo/input.h | 2 | ||||
| -rw-r--r-- | include/rodeo/window.h | 50 |
5 files changed, 228 insertions, 3 deletions
diff --git a/include/rodeo/audio.h b/include/rodeo/audio.h index dd7639d..14ae6f0 100644 --- a/include/rodeo/audio.h +++ b/include/rodeo/audio.h @@ -10,14 +10,25 @@ typedef struct rodeo_audio_sound_t rodeo_audio_sound_t; typedef struct rodeo_audio_music_t rodeo_audio_music_t; void -rodeo_audio_initialize( +rodeo_audio_init( uint32_t channels //uint32_t num_sound_pools, //uint32_t size_sound_pools ); void -rodeo_audio_deinitialize(void); +rodeo_audio_deinit(void); + +#define \ +mrodeo_audio_do( \ + channels \ +) \ + mrodeo_defer_do( \ + rodeo_audio_init( \ + channels \ + ), \ + rodeo_audio_deinit() \ + ) /* uint32_t diff --git a/include/rodeo/gfx.h b/include/rodeo/gfx.h new file mode 100644 index 0000000..28d46ff --- /dev/null +++ b/include/rodeo/gfx.h @@ -0,0 +1,98 @@ +#pragma once + +// -- internal -- +// public +#include "rodeo/gfx_t.h" + +// -- external -- +#include "stc/cstr.h" + +void +rodeo_gfx_init(void); + +void +rodeo_gfx_deinit(void); + +void +rodeo_gfx_frame_begin(void); + +void +rodeo_gfx_frame_end(void); + +cstr +rodeo_gfx_renderer_name_get(void); + +void +rodeo_gfx_renderer_flush(void); + +const rodeo_gfx_texture_2d_t* +rodeo_gfx_texture_2d_default_get(void); + +rodeo_gfx_texture_2d_t +rodeo_gfx_texture_2d_create_from_RGBA8( + const uint16_t width, + const uint16_t height, + const uint8_t memory[] +); + +rodeo_gfx_texture_2d_t +rodeo_gfx_texture_2d_create_from_path(cstr path); + +void +rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t *texture); + +void +rodeo_gfx_rectangle_draw( + const rodeo_rectangle_t *rectangle, + const rodeo_color_RGBAFloat_t *color +); + +void +rodeo_gfx_texture_2d_draw( + const rodeo_rectangle_t *destination, + const rodeo_rectangle_t *source, + const rodeo_color_RGBAFloat_t *color, + const rodeo_gfx_texture_2d_t *texture +); + +void +rodeo_gfx_renderer_flush(void); + +uint32_t +rodeo_gfx_frame_limit_get(void); + +cstr +rodeo_gfx_renderer_name_get(void); + +uint64_t +rodeo_gfx_frame_count_get(void); + +float +rodeo_gfx_frame_time_get(void); + +float +rodeo_gfx_frame_perSecond_get(void); + +void +rodeo_gfx_frame_limit_set(uint32_t limit); + +uint32_t +rodeo_gfx_frame_limit_get(void); + +#define \ +mrodeo_gfx_do( \ +) \ + mrodeo_defer_do( \ + rodeo_gfx_init(), \ + rodeo_gfx_deinit() \ + ) + + +#define \ +mrodeo_gfx_frame_do( \ +) \ + mrodeo_defer_do( \ + rodeo_gfx_frame_begin(), \ + rodeo_gfx_frame_end() \ + ) + diff --git a/include/rodeo/gfx_t.h b/include/rodeo/gfx_t.h new file mode 100644 index 0000000..9ed5f14 --- /dev/null +++ b/include/rodeo/gfx_t.h @@ -0,0 +1,66 @@ +#pragma once + +// -- internal -- +// public +#include "rodeo_types.h" +// -- system -- +#include <inttypes.h> + +typedef struct irodeo_gfx_texture_internal irodeo_gfx_texture_internal_t; + +typedef +struct +{ + irodeo_gfx_texture_internal_t *internal_texture; + uint32_t width; + uint32_t height; +} +rodeo_gfx_texture_2d_t; + +typedef +union +{ + struct + { + float red; + float green; + float blue; + float alpha; + } + colors; + float array[4]; +} +rodeo_color_RGBAFloat_t; + +typedef +union +{ + struct + { + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t alpha; + } + colors; + uint32_t rgba; + uint8_t array[4]; +} +rodeo_color_RGBA8_t; + +typedef +struct +{ + float x; + float y; + float z; + rodeo_color_RGBAFloat_t color; + //float red; + //float green; + //float blue; + //float alpha; + float texture_x; + float texture_y; + float texture_id; +} +rodeo_gfx_vertex_t; diff --git a/include/rodeo/input.h b/include/rodeo/input.h index 690d2d1..fe2b67d 100644 --- a/include/rodeo/input.h +++ b/include/rodeo/input.h @@ -4,7 +4,7 @@ #include "rodeo/input_t.h" bool -rodeo_input_events_poll(void); +rodeo_input_poll(void); void rodeo_input_command_register_callback( diff --git a/include/rodeo/window.h b/include/rodeo/window.h new file mode 100644 index 0000000..dd505f2 --- /dev/null +++ b/include/rodeo/window.h @@ -0,0 +1,50 @@ +#pragma once + +// -- internal -- +// public +//#include "rodeo/window_t.h" + +// -- external -- +#include "stc/cstr.h" + +// -- system -- +#include <inttypes.h> + + +void +rodeo_window_init( + uint16_t screen_height, + uint16_t screen_width, + cstr title +); + +void +rodeo_window_deinit(void); + +uint16_t +rodeo_window_screen_width_get(void); + +uint16_t +rodeo_window_screen_height_get(void); + +bool +rodeo_window_shouldQuit(void); + +void +rodeo_window_quit(void); + +#define \ +mrodeo_window_do( \ + screen_height, \ + screen_width, \ + title \ +) \ + mrodeo_defer_do( \ + rodeo_window_init( \ + screen_height, \ + screen_width, \ + title \ + ), \ + rodeo_window_deinit() \ + ) + |
