const std = @import("std"); const rgfw = @import("rgfw_raw"); const rsgl = @import("rsgl"); 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 { var hints: *rgfw.RGFW_glHints = rgfw.RGFW_getGlobalHints_OpenGL(); hints.major = 3; hints.minor = 3; hints.profile = rgfw.RGFW_glCompatibility; rgfw.RGFW_setGlobalHints_OpenGL(hints); 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); const renderer: *rsgl.renderer = rsgl.gl.rendererProc().init(@constCast(&rgfw.RGFW_getProcAddress_OpenGL)); renderer.viewport(rsgl.rect{.x=0,.y=0,.w=500,.h=500}); renderer.updateSize(500, 500); while(rgfw.RGFW_FALSE == rgfw.RGFW_window_shouldClose(win)) { rgfw.RGFW_pollEvents(); if(rgfw.RGFW_TRUE == rgfw.RGFW_isMousePressed(rgfw.RGFW_mouseLeft)) { std.debug.print("You clicked\n", .{}); } if(rgfw.RGFW_TRUE == rgfw.RGFW_isMousePressed(rgfw.RGFW_mouseRight)) { std.debug.print("The right mouse button was clicked\n", .{}); } renderer.clear(rsgl.color{.r=10,.g=50,.b=100,.a=0}); renderer.setColor(rsgl.color{.r=255,.g=0,.b=0,.a=255}); _ = renderer.drawRect(rsgl.rect{.x=200,.y=200,.w=200,.h=200}); renderer.render(); rgfw.RGFW_window_swapBuffers_OpenGL(win); } rgfw.RGFW_window_close(win); }