diff options
| author | realtradam <[email protected]> | 2023-01-06 15:53:53 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-01-06 15:53:53 -0500 |
| commit | 729a6b3b9cb0315106c87079a0eba9b294f02159 (patch) | |
| tree | 4d7062c70b13349685bd7dc39295af6b1dc64a25 /include | |
| parent | b1f855a82b40f1caeaf4d672638f2cfc933c8040 (diff) | |
| download | RodeoKit-729a6b3b9cb0315106c87079a0eba9b294f02159.tar.gz RodeoKit-729a6b3b9cb0315106c87079a0eba9b294f02159.zip | |
render batching for coloured rectangles
Diffstat (limited to 'include')
| -rw-r--r-- | include/rodeo.h | 61 | ||||
| -rw-r--r-- | include/rodeo_math.h | 7 | ||||
| -rw-r--r-- | include/rodeo_types.h | 57 |
3 files changed, 97 insertions, 28 deletions
diff --git a/include/rodeo.h b/include/rodeo.h index 86505f1..4686cb5 100644 --- a/include/rodeo.h +++ b/include/rodeo.h @@ -1,40 +1,23 @@ #include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <limits.h> + #include "SDL2/SDL.h" #include "SDL2/SDL_syswm.h" +#include "bgfx/c99/bgfx.h" -typedef -struct -Rodeo__\ -data_t -{ - SDL_Window* window; - SDL_Surface* screen_surface; - SDL_SysWMinfo wmi; - int screen_width; - int screen_height; - SDL_Event sdl_event; - bool quit; -} Rodeo__data_t; +#include "rodeo_types.h" -typedef -struct -Rodeo__\ -color_t -{ - float red; - float green; - float blue; - float alpha; -} Rodeo__color_t; void Rodeo__\ init_window( - Rodeo__data_t* state, - int screen_height, - int screen_width, - char* title - ); + Rodeo__data_t* state, + int screen_height, + int screen_width, + char* title +); void Rodeo__\ @@ -56,3 +39,25 @@ void Rodeo__\ draw_debug_text(u_int16_t x, u_int16_t y, const char *format, ...); +const char * +Rodeo__\ +get_renderer_name_as_string(); + +void +Rodeo__\ +flush_batch(Rodeo__data_t *state); + +void +Rodeo__\ +draw_rectangle( + Rodeo__data_t *state, + u_int16_t x, + u_int16_t y, + u_int16_t width, + u_int16_t height, + struct Rodeo__color_rgba_t color +); + +bgfx_shader_handle_t +Rodeo__\ +load_shader(const char* path); diff --git a/include/rodeo_math.h b/include/rodeo_math.h new file mode 100644 index 0000000..13db9b3 --- /dev/null +++ b/include/rodeo_math.h @@ -0,0 +1,7 @@ +#include "stdint.h" +#include "rodeo_types.h" + +uint32_t +Rodeo__\ +Math__\ +color_rgba_to_uint32(const struct Rodeo__color_rgba_t color); diff --git a/include/rodeo_types.h b/include/rodeo_types.h new file mode 100644 index 0000000..08748e5 --- /dev/null +++ b/include/rodeo_types.h @@ -0,0 +1,57 @@ +#pragma once +#include <stdbool.h> +#include <stdint.h> + +#include "SDL2/SDL.h" +#include "SDL2/SDL_syswm.h" +#include "bgfx/c99/bgfx.h" + +#define RODEO__MAX_VERTEX_SIZE 8192 + +typedef +struct +Rodeo__\ +color_rgba_t +{ + float red; + float green; + float blue; + float alpha; +} Rodeo__color_t; + +typedef +struct +Rodeo__\ +position_color_vertex_t +{ + float x; + float y; + float z; + uint32_t abgr; +} Rodeo__position_color_vertex_t; + +typedef +struct +Rodeo__\ +data_t +{ + SDL_Window* window; + SDL_Surface* screen_surface; + SDL_SysWMinfo wmi; + int screen_width; + int screen_height; + SDL_Event sdl_event; + bool quit; + + bgfx_vertex_layout_t vertex_layout; + 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]; + 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; |
