const std = @import("std"); const rgfw = @import("rgfw.zig"); fn keyfunc (event: [*c]const rgfw.RGFW_event) callconv(.c) void { if(event.*.key.value == rgfw.RGFW_keyEscape) { rgfw.RGFW_window_setShouldClose(event.*.common.win, 1); } } pub fn main() !void { const win: ?*rgfw.RGFW_window = rgfw.RGFW_createWindow("a window", 0, 0, 800, 600, rgfw.RGFW_windowCenter | rgfw.RGFW_windowNoResize | rgfw.RGFW_windowOpenGL); _ = rgfw.RGFW_setEventCallback(rgfw.RGFW_keyPressed, keyfunc); var mouseX: i32 = 0; var mouseY: i32 = 0; while(rgfw.RGFW_FALSE == rgfw.RGFW_window_shouldClose(win)) { var event: rgfw.RGFW_event = undefined; while(rgfw.RGFW_TRUE == rgfw.RGFW_window_checkEvent(win, &event)) { _ = rgfw.RGFW_window_getMouse(win, &mouseX, &mouseY); if(event.type == rgfw.RGFW_mouseButtonPressed and event.button.value == rgfw.RGFW_mouseLeft) { std.debug.print("You clicked at x: {d}, y: {d}\n", .{mouseX, mouseY}); } } if(rgfw.RGFW_TRUE == rgfw.RGFW_isMousePressed(rgfw.RGFW_mouseRight)) { std.debug.print("The right mouse button was clicked at x: {d}, y: {d}\n", .{mouseX, mouseY}); } rgfw.RGFW_window_swapBuffers_OpenGL(win); } rgfw.RGFW_window_close(win); }