parent
308d413f09
commit
15dfb2867a
15 changed files with 21 additions and 21 deletions
|
|
@ -54,7 +54,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
while (core.pollEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| switch (ev.key) {
|
||||
.q, .escape, .space => core.setShouldClose(true),
|
||||
.q, .escape, .space => core.close(),
|
||||
.w, .up => {
|
||||
app.keys |= Dir.up;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,5 +82,5 @@ pub fn init(_: *App, core: *mach.Core) !void {
|
|||
pub fn deinit(_: *App, _: *mach.Core) void {}
|
||||
|
||||
pub fn update(_: *App, core: *mach.Core) !void {
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
if (ev.key == .space)
|
||||
core.setShouldClose(true);
|
||||
core.close();
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ pub fn update(app: *App, core: *mach.Core) !void {
|
|||
app.fragment_shader_file.seekTo(0) catch unreachable;
|
||||
app.fragment_shader_code = app.fragment_shader_file.readToEndAllocOptions(core.allocator, std.math.maxInt(u32), null, 1, 0) catch |err| {
|
||||
std.log.err("Err: {}", .{err});
|
||||
return core.setShouldClose(true);
|
||||
return core.close();
|
||||
};
|
||||
app.pipeline = recreatePipeline(core, app.fragment_shader_code, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ pub fn setOptions(core: *Core, options: structs.Options) !void {
|
|||
}
|
||||
|
||||
// Signals mach to stop the update loop.
|
||||
pub fn setShouldClose(core: *Core, value: bool) void {
|
||||
core.internal.setShouldClose(value);
|
||||
pub fn close(core: *Core) void {
|
||||
core.internal.close();
|
||||
}
|
||||
|
||||
// Sets seconds to wait for an event with timeout before calling update()
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ pub fn update(_: *App, _: *Core) !void {}
|
|||
// 2. Core might need to expose more state so more API functions can be exposed (for example, the WebGPU API)
|
||||
// 3. Be very careful about arguments, types, memory, etc - any mismatch will result in undefined behavior
|
||||
|
||||
pub export fn mach_core_set_should_close(core: *Core) void {
|
||||
core.setShouldClose(true);
|
||||
pub export fn mach_core_close(core: *Core) void {
|
||||
core.close();
|
||||
}
|
||||
|
||||
pub export fn mach_core_delta_time(core: *Core) f32 {
|
||||
|
|
|
|||
|
|
@ -329,8 +329,8 @@ pub const Platform = struct {
|
|||
if (options.headless) platform.window.hide() catch {};
|
||||
}
|
||||
|
||||
pub fn setShouldClose(platform: *Platform, value: bool) void {
|
||||
platform.window.setShouldClose(value);
|
||||
pub fn close(platform: *Platform) void {
|
||||
platform.window.setShouldClose(true);
|
||||
}
|
||||
|
||||
pub fn getFramebufferSize(platform: *Platform) structs.Size {
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ pub const Platform = struct {
|
|||
js.machCanvasSetFullscreen(platform.id, options.fullscreen);
|
||||
}
|
||||
|
||||
pub fn setShouldClose(_: *Platform, value: bool) void {
|
||||
if (value) js.machEmitCloseEvent();
|
||||
pub fn close(_: *Platform) void {
|
||||
js.machEmitCloseEvent();
|
||||
}
|
||||
|
||||
pub fn setWaitEvent(_: *Platform, timeout: f64) void {
|
||||
|
|
@ -297,7 +297,7 @@ export fn wasmUpdate() void {
|
|||
core.delta_time_ns = core.timer.lapPrecise();
|
||||
core.delta_time = @intToFloat(f32, core.delta_time_ns) / @intToFloat(f32, std.time.ns_per_s);
|
||||
|
||||
app.update(&core) catch core.setShouldClose(true);
|
||||
app.update(&core) catch core.close();
|
||||
}
|
||||
|
||||
export fn wasmDeinit() void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue