mach: expose window size (pixel units, vs. framebuffer subpixel units)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
1e8ad533e2
commit
a7e7dc800d
2 changed files with 15 additions and 0 deletions
|
|
@ -34,10 +34,20 @@ pub const Core = struct {
|
||||||
core.internal.setShouldClose(value);
|
core.internal.setShouldClose(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the framebuffer size, in subpixel units.
|
||||||
|
//
|
||||||
|
// e.g. returns 1280x960 on macOS for a window that is 640x480
|
||||||
pub fn getFramebufferSize(core: *Core) !structs.Size {
|
pub fn getFramebufferSize(core: *Core) !structs.Size {
|
||||||
return core.internal.getFramebufferSize();
|
return core.internal.getFramebufferSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the widow size, in pixel units.
|
||||||
|
//
|
||||||
|
// e.g. returns 1280x960 on macOS for a window that is 640x480
|
||||||
|
pub fn getWindowSize(core: *Core) !structs.Size {
|
||||||
|
return core.internal.getWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setSizeLimits(core: *Core, min: structs.SizeOptional, max: structs.SizeOptional) !void {
|
pub fn setSizeLimits(core: *Core, min: structs.SizeOptional, max: structs.SizeOptional) !void {
|
||||||
return core.internal.setSizeLimits(min, max);
|
return core.internal.setSizeLimits(min, max);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,11 @@ pub const CoreGlfw = struct {
|
||||||
return @bitCast(structs.Size, size);
|
return @bitCast(structs.Size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getWindowSize(self: *CoreGlfw) !structs.Size {
|
||||||
|
const size = try self.window.getSize();
|
||||||
|
return @bitCast(structs.Size, size);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setSizeLimits(self: *CoreGlfw, min: structs.SizeOptional, max: structs.SizeOptional) !void {
|
pub fn setSizeLimits(self: *CoreGlfw, min: structs.SizeOptional, max: structs.SizeOptional) !void {
|
||||||
try self.window.setSizeLimits(
|
try self.window.setSizeLimits(
|
||||||
@bitCast(glfw.Window.SizeOptional, min),
|
@bitCast(glfw.Window.SizeOptional, min),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue