src/window.c

changeset 237
2ea35c5f4760
parent 231
0da563c4e39c
--- a/src/window.c	Fri Aug 01 17:58:28 2025 +0200
+++ b/src/window.c	Fri Aug 01 18:18:57 2025 +0200
@@ -222,8 +222,22 @@
     SDL_SetWindowTitle(asc_context.windows[index].window, title);
 }
 
+void asc_window_set_position(unsigned index, asc_vec2i pos) {
+    assert(asc_context.windows[index].window != NULL);
+    SDL_SetWindowPosition(asc_context.windows[index].window, pos.x, pos.y);
+}
+
+void asc_window_center(unsigned index) {
+    // TODO: add support for multiple displays
+    // TODO: add support for centering just one axis
+    assert(asc_context.windows[index].window != NULL);
+    SDL_SetWindowPosition(asc_context.windows[index].window,
+        SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
+}
+
 void asc_window_set_size(unsigned index, asc_vec2u size) {
     assert(asc_context.windows[index].window != NULL);
     asc_context.windows[index].dimensions = size;
+    // TODO: check what needs to be changed when SDL_WINDOW_ALLOW_HIGHDPI is supported by the engine
     SDL_SetWindowSize(asc_context.windows[index].window, (int)size.width, (int)size.height);
 }

mercurial