Cleaned up user data debugging code

This commit is contained in:
Brandon Dyck 2022-01-09 12:28:45 -07:00
parent c12c0ea0fb
commit 95daf52b70

View File

@ -99,17 +99,10 @@ const Buffer = struct {
}; };
fn handleActive(win: mfb.Window(State), isActive: bool) callconv(.C) void { fn handleActive(win: mfb.Window(State), isActive: bool) callconv(.C) void {
// win.getUserData().?.*.active = isActive; win.getUserData().?.*.active = isActive;
var data = win.getUserData(); var data = win.getUserData();
std.log.info("got data", .{});
if (data) |value| { if (data) |value| {
// value.*.active = isActive; value.*.active = isActive;
_ = value;
}
if (isActive) {
std.log.info("activated!!!!!!!!!!!!", .{});
} else {
std.log.info("deactivated", .{});
} }
} }
@ -121,7 +114,7 @@ pub fn main() !void {
defer state.deinit(); defer state.deinit();
var win = mfb.Window(State).open("Hello minifb-zig", Width, Height, .{ .resizable = true, .alwaysOnTop = true }) catch unreachable; var win = mfb.Window(State).open("Hello minifb-zig", Width, Height, .{ .resizable = true, .alwaysOnTop = true }) catch unreachable;
mfb.setTargetFPS(7); mfb.setTargetFPS(30);
win.setUserData(&state); win.setUserData(&state);
win.setActiveCallback(handleActive); win.setActiveCallback(handleActive);
@ -129,11 +122,6 @@ pub fn main() !void {
var buf = try Buffer.init(alloc, Width, Height); var buf = try Buffer.init(alloc, Width, Height);
defer buf.deinit(); defer buf.deinit();
var aliasedState = win.getUserData();
if (aliasedState) |value| {
std.log.info("Period: {d}", .{value.*.period});
}
state.render(buf); state.render(buf);
while (win.waitSync()) { while (win.waitSync()) {
state.render(buf); state.render(buf);