diff --git a/build.zig b/build.zig index 900dbbd..4d7ae19 100644 --- a/build.zig +++ b/build.zig @@ -45,6 +45,63 @@ pub fn build(b: *std.Build) !void { const incbin_dep = b.dependency("incbin", .{}); mod.addIncludePath(incbin_dep.path(".")); + { + const imgui_mod = b.createModule(.{ + .target = target, + .optimize = optimize, + .link_libcpp = true, + }); + + const imgui = b.dependency("imgui", .{}); + imgui_mod.addCSourceFiles(.{ + .root = imgui.path("."), + .files = &.{ + "imgui.cpp", + "imgui_demo.cpp", + "imgui_draw.cpp", + "imgui_tables.cpp", + "imgui_widgets.cpp", + }, + .flags = &.{ + "-fno-sanitize=undefined", + "-std=c++11", + "-Wno-deprecated-declarations", + "-DNO_FONT_AWESOME", + }, + }); + imgui_mod.addIncludePath(imgui.path(".")); + + const imgui_lib = b.addLibrary(.{ + .name = "imgui", + .root_module = imgui_mod + }); + imgui_lib.installHeadersDirectory(imgui.path("."), "imgui", .{}); + imgui_lib.installHeadersDirectory(imgui.path("."), ".", .{}); + + mod.linkLibrary(imgui_lib); + } + + const cimgui = b.dependency("cimgui", .{}); + mod.addCSourceFile(.{ + .file = cimgui.path("cimgui.cpp"), + .flags = &.{ + "-fno-exceptions", + "-fno-rtti", + "-std=c++11" + }, + }); + mod.addIncludePath(cimgui.path(".")); + + const rlimgui = b.dependency("rlimgui", .{ + .target = target, + .optimize = optimize, + }); + mod.addCSourceFile(.{ + .file = rlimgui.path("rlImGui.cpp"), + .flags = &.{}, + }); + mod.addIncludePath(rlimgui.path(".")); + const exe = b.addExecutable(.{ .name = "gaem", .root_module = mod diff --git a/build.zig.zon b/build.zig.zon index 88d8b81..2e6a395 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -17,6 +17,18 @@ .url = "https://github.com/the-argus/zig-compile-commands/archive/f74e2d13e43fafab3a71e19557a0e1cfbf0f2e1b.tar.gz", .hash = "zig_compile_commands-0.0.1-OZg5-a3CAACM-h32Kjb1obTMqrKGs9YoDhorVZ8-LGle", }, + .imgui = .{ + .url = "https://github.com/ocornut/imgui/archive/6d910d5487d11ca567b61c7824b0c78c569d62f0.tar.gz", + .hash = "N-V-__8AALp9cwA8tEuEno2YCZyivsMaobnF-Z7qZGY3qBOt", + }, + .rlimgui = .{ + .url = "https://github.com/raylib-extras/rlImGui/archive/dc7f97679a024eee8f5f009e77cc311748200415.tar.gz", + .hash = "N-V-__8AAC-taQCKZ-3IjRuWJ-5Dc47QKHDPEmqlwXhvjBGq", + }, + .cimgui = .{ + .url = "https://github.com/cimgui/cimgui/archive/bfd30140a9c5832b5e0dcf179d6e1e5c69373d5a.tar.gz", + .hash = "N-V-__8AAOY-OACWjhmHu289AXFy9Fro3w_30mGFYL8FTq71", + } }, .minimum_zig_version = "0.15.2", .paths = .{""}, diff --git a/src/main.c b/src/main.c index b50aa57..be8b77d 100644 --- a/src/main.c +++ b/src/main.c @@ -86,11 +86,15 @@ int main(void) SetWindowState(FLAG_WINDOW_RESIZABLE); SetTargetFPS(60); + rlImGuiSetup(true); + resources_init(&g_resources); struct Game game = { 0 }; game_init(&game); + bool open = true; + while (!WindowShouldClose()) { TracyCFrameMark; @@ -115,10 +119,15 @@ int main(void) game_tick(&game); end_window_scaling(&transform, BLACK); + rlImGuiBegin(); + if (open) igShowDemoWindow(&open); + rlImGuiEnd(); + EndDrawing(); } game_free(&game); + rlImGuiShutdown(); CloseWindow(); return 0; diff --git a/src/main.h b/src/main.h index d5d490c..b6b396d 100644 --- a/src/main.h +++ b/src/main.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,9 @@ #include #include +#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS +#include + #define INCBIN_STYLE INCBIN_STYLE_SNAKE #define INCBIN_PREFIX #include