aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_window.c
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-05-02 22:11:23 +1200
committerArslaan Pathan <[email protected]>2026-05-02 22:11:23 +1200
commitb1f6b4711cb5473adaa8123c8a3dd1cc954a8c31 (patch)
treef448a1c8c3a656e7b07ea9feaa0a6070f9f904ee /src/saffron_window.c
parent5e43ce6764ed702bfb8fb9719051d42f1e841e34 (diff)
downloadsaffron-b1f6b4711cb5473adaa8123c8a3dd1cc954a8c31.tar.xz
saffron-b1f6b4711cb5473adaa8123c8a3dd1cc954a8c31.zip
GL context things
Diffstat (limited to 'src/saffron_window.c')
-rw-r--r--src/saffron_window.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/saffron_window.c b/src/saffron_window.c
index 6c89c50..a909bc3 100644
--- a/src/saffron_window.c
+++ b/src/saffron_window.c
@@ -21,19 +21,30 @@ SaffronWindow* saffron_window_new(const char* title, int w, int h) {
Uint32 flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_OPENGL;
window->sdl_window = SDL_CreateWindow(title, w, h, flags);
+
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles2");
window->renderer = SDL_CreateRenderer(window->sdl_window, NULL);
+
+ window->gl_context = SDL_GL_CreateContext(window->sdl_window);
+ SDL_GL_MakeCurrent(window->sdl_window, window->gl_context);
+
window->root->theme = SF_MACRO_DEFAULT_THEME;
return window;
}
void saffron_window_free(SaffronWindow* window) {
+ SDL_GL_DestroyContext(window->gl_context);
SDL_DestroyRenderer(window->renderer);
SDL_DestroyWindow(window->sdl_window);
saffron_widget_free(window->root);
free(window);
}
+SDL_GLContext saffron_window_get_gl_context(SaffronWindow* window) {
+ return window->gl_context;
+}
+
static void handle_mouse_down(SDL_Event* event, SaffronWindow* window) {
if (event->type != SDL_EVENT_MOUSE_BUTTON_DOWN) return;
@@ -93,6 +104,7 @@ 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);