aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/saffron_api.h3
-rw-r--r--src/saffron_window.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/include/saffron_api.h b/include/saffron_api.h
index 99b4988..5a8935e 100644
--- a/include/saffron_api.h
+++ b/include/saffron_api.h
@@ -47,4 +47,7 @@ void saffron_hook_sdl_all_events(SaffronWindow* window, bool (*callback)(SDL_Eve
SDL_GLContext saffron_window_get_gl_context(SaffronWindow* window);
+void saffron_window_detach_gl_context(SaffronWindow* window);
+void saffron_window_reattach_gl_context(SaffronWindow* window);
+
#endif
diff --git a/src/saffron_window.c b/src/saffron_window.c
index a909bc3..085ee20 100644
--- a/src/saffron_window.c
+++ b/src/saffron_window.c
@@ -1,3 +1,4 @@
+#include "saffron_api.h"
#include "saffron_theme.h"
#include <SDL3/SDL_render.h>
#include <SDL3/SDL_video.h>
@@ -74,6 +75,14 @@ static void handle_window_resized(SDL_Event* event, SaffronWindow* window) {
saffron_box_layout((SaffronBox*)window->root);
}
+void saffron_window_detach_gl_context(SaffronWindow *window) {
+ SDL_GL_MakeCurrent(window->sdl_window, NULL);
+}
+
+void saffron_window_reattach_gl_context(SaffronWindow *window) {
+ SDL_GL_MakeCurrent(window->sdl_window, window->gl_context);
+}
+
void saffron_window_main(SaffronWindow *window) {
if (!window) return;
@@ -104,7 +113,6 @@ void saffron_window_main(SaffronWindow *window) {
SDL_SetRenderDrawColor(window->renderer, 0, 0, 0, 255);
SDL_RenderClear(window->renderer);
- SDL_GL_MakeCurrent(window->sdl_window, window->gl_context); // just in case!
saffron_widget_draw(window->root, window->renderer);
SDL_RenderPresent(window->renderer);