examples: use engine.core.setKeyCallback() instead of accessing glfw directly

This commit is contained in:
iddev5 2022-05-09 12:55:45 +05:30 committed by Stephen Gutekanst
parent 5396769227
commit 1f95bd48df
6 changed files with 18 additions and 32 deletions

View file

@ -26,13 +26,11 @@ const App = @This();
pub fn init(app: *App, engine: *mach.Engine) !void {
timer = try std.time.Timer.start();
engine.core.internal.window.setKeyCallback(struct {
fn callback(window: glfw.Window, key: glfw.Key, scancode: i32, action: glfw.Action, mods: glfw.Mods) void {
_ = scancode;
_ = mods;
engine.core.setKeyCallback(struct {
fn callback(_: *App, eng: *mach.Engine, key: mach.Key, action: mach.Action) void {
if (action == .press) {
switch (key) {
.space => window.setShouldClose(true),
.space => eng.core.internal.window.setShouldClose(true),
else => {},
}
}