]> git.nega.tv - josh/narcissus/commitdiff
narcissus-app: Add HIDPI support
authorJosh Simmons <josh@nega.tv>
Thu, 9 May 2024 08:59:13 +0000 (10:59 +0200)
committerJosh Simmons <josh@nega.tv>
Thu, 9 May 2024 09:00:49 +0000 (11:00 +0200)
engine/narcissus-app/src/lib.rs
engine/narcissus-app/src/sdl.rs

index a8baa7f6b7dbd9008d4b375100f6c1aea36804ac..dc6205dd5f2e00b2d747cd7041b12b8bb612627c 100644 (file)
@@ -36,6 +36,7 @@ pub trait Window: AsRawWindow + Upcast<dyn AsRawWindow> {
     fn id(&self) -> WindowId;
 
     fn extent(&self) -> (u32, u32);
+    fn drawable_extent(&self) -> (u32, u32);
 }
 
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
index f3d6e4f5032c19ffe943f04ead9faf4bfc9a4f41..4e39553f6fad7310b222f805ba091c7b9eeff880 100644 (file)
@@ -22,6 +22,15 @@ impl Window for SdlWindow {
     }
 
     fn extent(&self) -> (u32, u32) {
+        let mut width = 0;
+        let mut height = 0;
+        unsafe {
+            sdl::SDL_GetWindowSize(self.window, &mut width, &mut height);
+        }
+        (width as u32, height as u32)
+    }
+
+    fn drawable_extent(&self) -> (u32, u32) {
         let mut width = 0;
         let mut height = 0;
         unsafe {
@@ -96,7 +105,10 @@ impl App for SdlApp {
                 0,
                 desc.width as i32,
                 desc.height as i32,
-                sdl::WINDOW_VULKAN | sdl::WINDOW_SHOWN | sdl::WINDOW_RESIZABLE,
+                sdl::WINDOW_VULKAN
+                    | sdl::WINDOW_SHOWN
+                    | sdl::WINDOW_RESIZABLE
+                    | sdl::WINDOW_ALLOW_HIGHDPI,
             )
         };
         assert!(!window.is_null());