From e53d1dd0aab5859cc8828fa1f306df8495abc1e0 Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sun, 9 Jan 2022 19:31:27 -0700 Subject: [PATCH] Implemented getMonitorScale --- lib/minifb/src/minifb.zig | 13 +++++++++++++ src/main.zig | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/minifb/src/minifb.zig b/lib/minifb/src/minifb.zig index cfad8ff..4d60f5c 100644 --- a/lib/minifb/src/minifb.zig +++ b/lib/minifb/src/minifb.zig @@ -98,6 +98,19 @@ pub fn Window(comptime TUserData: type) type { pub fn setViewport(self: Window(TUserData), offset_x: u32, offset_y: u32, width: u32, height: u32) bool { return c.mfb_set_viewport(self.cwin, offset_x, offset_y, width, height); } + + pub const MonitorScale = struct { + x: f32, + y: f32, + }; + pub fn getMonitorScale(self: Window(TUserData)) MonitorScale { + var scale = MonitorScale{ + .x = undefined, + .y = undefined, + }; + c.mfb_get_monitor_scale(self.cwin, &scale.x, &scale.y); + return scale; + } }; } diff --git a/src/main.zig b/src/main.zig index 934383f..91c6ecc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -140,6 +140,8 @@ pub fn main() !void { defer state.deinit(); var win = mfb.Window(State).open("Hello minifb-zig", Width, Height, .{ .resizable = true, .alwaysOnTop = true }) catch unreachable; + const scale = win.getMonitorScale(); + std.log.info("Monitor scale: {d} * {d}", .{scale.x, scale.y}); mfb.setTargetFPS(30); win.setUserData(&state);