aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_window.c
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-08 18:21:40 +1200
committerArslaan Pathan <[email protected]>2026-04-08 18:21:40 +1200
commit0f19e5f0175b0e031257ccd22f42e21baaf2f720 (patch)
treecee391e4de8b22470c143239f826055908eb1c60 /src/saffron_window.c
parentc9660a840256308d4dde40613a1af3296d3fdead (diff)
downloadsaffron-0f19e5f0175b0e031257ccd22f42e21baaf2f720.tar.xz
saffron-0f19e5f0175b0e031257ccd22f42e21baaf2f720.zip
Implement saffron_window_main and saffron_quit, among a few other missing APIs, and get an actual API test to work.
IT WORKS IT WORKS IT WORKS THIS IS SO PEAK IT WORKS OHMYGOD IT WORKS FINALLY IT WORKS IT WORKS IT WOORKSKSKSKSKKS!!!!!!
Diffstat (limited to 'src/saffron_window.c')
-rw-r--r--src/saffron_window.c24
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
+ }
+}