mach: render during resize

This commit is contained in:
Ali Chraghi 2022-12-28 20:44:42 +03:30 committed by Stephen Gutekanst
parent 69cbe954ac
commit c26592ea89

View file

@ -299,6 +299,7 @@ pub const Platform = struct {
const pf = (window.getUserPointer(UserPtr) orelse unreachable).platform; const pf = (window.getUserPointer(UserPtr) orelse unreachable).platform;
pf.last_framebuffer_size.width = width; pf.last_framebuffer_size.width = width;
pf.last_framebuffer_size.height = height; pf.last_framebuffer_size.height = height;
render(pf.core) catch {};
} }
}.callback; }.callback;
platform.window.setFramebufferSizeCallback(framebuffer_size_callback); platform.window.setFramebufferSizeCallback(framebuffer_size_callback);
@ -592,6 +593,11 @@ pub fn main() !void {
defer app.deinit(core); defer app.deinit(core);
while (!core.internal.window.shouldClose()) { while (!core.internal.window.shouldClose()) {
try render(core);
}
}
fn render(core: *Core) !void {
// On Darwin targets, Dawn requires an NSAutoreleasePool per frame to release // On Darwin targets, Dawn requires an NSAutoreleasePool per frame to release
// some resources. See Dawn's CHelloWorld example. // some resources. See Dawn's CHelloWorld example.
const pool = try util.AutoReleasePool.init(); const pool = try util.AutoReleasePool.init();
@ -601,7 +607,6 @@ pub fn main() !void {
try app.update(core); try app.update(core);
} }
}
pub fn coreInit(allocator: std.mem.Allocator) !*Core { pub fn coreInit(allocator: std.mem.Allocator) !*Core {
const core: *Core = try allocator.create(Core); const core: *Core = try allocator.create(Core);