src/window.c

changeset 295
c72df1f06671
parent 294
4df350dac84f
--- a/src/window.c	Sun Jan 25 13:49:49 2026 +0100
+++ b/src/window.c	Sun Jan 25 14:07:50 2026 +0100
@@ -146,11 +146,8 @@
     // necessary safeguard
     if (window->id == 0) return;
 
-    // active the window that shall be synced temporarily
-    unsigned int active_index = asc_context.active_window;
-    if (index != active_index) {
-        asc_window_activate(index);
-    }
+    // activate the window that shall be synced temporarily
+    unsigned int active_index = asc_window_activate(index);
 
     // Clear the color buffer for the window frame
     glViewport(0, 0,
@@ -196,14 +193,17 @@
     window->resized = false;
     window->moved = false;
 
-    if (index != active_index) {
-        asc_window_activate(active_index);
-    }
+    asc_window_activate(active_index);
 }
 
-void asc_window_activate(unsigned int index) {
-    asc_context.active_window = index;
-    asc_gl_context_activate(&asc_active_window->glctx);
+unsigned int asc_window_activate(unsigned int index) {
+    unsigned int active_index = asc_context.active_window;
+    if (active_index != index) {
+        asc_context.active_window = index;
+        asc_gl_context_activate(&asc_active_window->glctx);
+        return active_index;
+    }
+    return index;
 }
 
 unsigned int asc_window_index(Uint32 id) {
@@ -273,3 +273,15 @@
     // TODO: check what needs to be changed when SDL_WINDOW_ALLOW_HIGHDPI is supported by the engine
     SDL_SetWindowSize(window->sdl, (int)size.width, (int)size.height);
 }
+
+void asc_window_fullscreen(unsigned index, bool fullscreen) {
+    const AscWindow *window = asc_context.windows + index;
+    assert(window->sdl != NULL);
+    SDL_SetWindowFullscreen(window->sdl, fullscreen);
+}
+
+void asc_window_vsync(unsigned index, bool vsync) {
+    unsigned int active_index = asc_window_activate(index);
+    SDL_GL_SetSwapInterval(vsync ? 1 : 0);
+    asc_window_activate(active_index);
+}

mercurial