diff options
Diffstat (limited to 'src/saffron_window.c')
| -rw-r--r-- | src/saffron_window.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/saffron_window.c b/src/saffron_window.c index 10adfce..4bdae76 100644 --- a/src/saffron_window.c +++ b/src/saffron_window.c @@ -1,3 +1,4 @@ +#include <SDL3/SDL_events.h> #include <stdlib.h> #include <SDL3/SDL.h> #include <SDL3_ttf/SDL_ttf.h> @@ -22,3 +23,26 @@ void saffron_window_free(SaffronWindow* window) { saffron_widget_free(window->root); free(window); } + +void saffron_window_main(SaffronWindow *window) { + if (!window) return; + + bool running = true; + SDL_Event event; + + while (running) { + while (SDL_PollEvent(&event)) { + if (event.type == SDL_EVENT_QUIT) { + running = false; + } + // TODO: send events to widgets and stuff + } + + SDL_SetRenderDrawColor(window->renderer, 0, 0, 0, 255); + SDL_RenderClear(window->renderer); + saffron_widget_draw(window->root, window->renderer); + SDL_RenderPresent(window->renderer); + + SDL_Delay(16); // around 60fps or so + } +} |
