mach: correct vsync mode setting

This correctly sets presentation modes for vsync, both at startup and at runtime via
a `setOptions` request.

Note: There may still be platforms where setting vsync is not enough, and a frame rate
limiter is needed to achieve proper synchronization. This is tracked in hexops/mach#444
and not fixed by this change.

Fixes hexops/mach#307

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-18 10:33:32 -07:00
parent edc3b5d60e
commit eb0eceb707
3 changed files with 19 additions and 11 deletions

View file

@ -34,15 +34,11 @@ target_desc: gpu.SwapChain.Descriptor,
internal: platform.Type,
pub fn init(allocator: std.mem.Allocator) !Core {
var core: Core = undefined;
pub fn init(allocator: std.mem.Allocator, core: *Core) !void {
core.allocator = allocator;
core.options = structs.Options{};
core.timer = try Timer.start();
core.internal = try platform.Type.init(allocator, &core);
return core;
core.internal = try platform.Type.init(allocator, core);
}
/// Set runtime options for application, like title, window size etc.