From 628f600abe6bb89bf370a414aae57778b4fbddfe Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Thu, 24 Mar 2022 14:16:35 +0100 Subject: [PATCH] use raygui --- build.zig | 1 + src/main.zig | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 82edbfb..138e55f 100644 --- a/build.zig +++ b/build.zig @@ -18,6 +18,7 @@ pub fn build(b: *std.build.Builder) void { const ray = raylib.Pkg("./3rdparty/raylib/src").addRaylib(b, exe.target); exe.linkLibrary(ray); exe.addIncludeDir("./3rdparty/raylib/src"); + exe.addIncludeDir("./3rdparty/raygui/src"); exe.setBuildMode(mode); exe.install(); diff --git a/src/main.zig b/src/main.zig index 47404c4..10f9d25 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2,6 +2,10 @@ const std = @import("std"); const ray = @cImport({ @cInclude("raylib.h"); }); +const raygui = @cImport({ + @cDefine("RAYGUI_IMPLEMENTATION", {}); + @cInclude("raygui.h"); +}); pub fn main() anyerror!void { std.log.info("All your codebase are belong to us.", .{}); @@ -9,15 +13,17 @@ pub fn main() anyerror!void { ray.InitWindow(800, 450, "ray [core] example - basic window"); defer ray.CloseWindow(); - while (!ray.WindowShouldClose()) - { + while (!ray.WindowShouldClose()) { ray.BeginDrawing(); defer ray.EndDrawing(); ray.ClearBackground(ray.RAYWHITE); ray.DrawText("Congrats! You created your first window!", 190, 200, 20, ray.LIGHTGRAY); - } + if (raygui.GuiButton(raygui.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) { + std.log.info("Button pressed", .{}); + } + } } test "basic test" {