Implemented getMonitorScale

This commit is contained in:
Brandon Dyck 2022-01-09 19:31:27 -07:00
parent 68e1402260
commit e53d1dd0aa
2 changed files with 15 additions and 0 deletions

View File

@ -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;
}
};
}

View File

@ -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);