integrate imgui
This commit is contained in:
parent
6c79f701d3
commit
be1cb0ba9f
57
build.zig
57
build.zig
@ -45,6 +45,63 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const incbin_dep = b.dependency("incbin", .{});
|
const incbin_dep = b.dependency("incbin", .{});
|
||||||
mod.addIncludePath(incbin_dep.path("."));
|
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(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "gaem",
|
.name = "gaem",
|
||||||
.root_module = mod
|
.root_module = mod
|
||||||
|
|||||||
@ -17,6 +17,18 @@
|
|||||||
.url = "https://github.com/the-argus/zig-compile-commands/archive/f74e2d13e43fafab3a71e19557a0e1cfbf0f2e1b.tar.gz",
|
.url = "https://github.com/the-argus/zig-compile-commands/archive/f74e2d13e43fafab3a71e19557a0e1cfbf0f2e1b.tar.gz",
|
||||||
.hash = "zig_compile_commands-0.0.1-OZg5-a3CAACM-h32Kjb1obTMqrKGs9YoDhorVZ8-LGle",
|
.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",
|
.minimum_zig_version = "0.15.2",
|
||||||
.paths = .{""},
|
.paths = .{""},
|
||||||
|
|||||||
@ -86,11 +86,15 @@ int main(void)
|
|||||||
SetWindowState(FLAG_WINDOW_RESIZABLE);
|
SetWindowState(FLAG_WINDOW_RESIZABLE);
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
|
|
||||||
|
rlImGuiSetup(true);
|
||||||
|
|
||||||
resources_init(&g_resources);
|
resources_init(&g_resources);
|
||||||
|
|
||||||
struct Game game = { 0 };
|
struct Game game = { 0 };
|
||||||
game_init(&game);
|
game_init(&game);
|
||||||
|
|
||||||
|
bool open = true;
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
TracyCFrameMark;
|
TracyCFrameMark;
|
||||||
@ -115,10 +119,15 @@ int main(void)
|
|||||||
game_tick(&game);
|
game_tick(&game);
|
||||||
end_window_scaling(&transform, BLACK);
|
end_window_scaling(&transform, BLACK);
|
||||||
|
|
||||||
|
rlImGuiBegin();
|
||||||
|
if (open) igShowDemoWindow(&open);
|
||||||
|
rlImGuiEnd();
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
game_free(&game);
|
game_free(&game);
|
||||||
|
rlImGuiShutdown();
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
|
#include <rlImGui.h>
|
||||||
#include <rlgl.h>
|
#include <rlgl.h>
|
||||||
#include <TracyConfig.h>
|
#include <TracyConfig.h>
|
||||||
#include <tracy/TracyC.h>
|
#include <tracy/TracyC.h>
|
||||||
@ -14,6 +15,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
|
#include <cimgui.h>
|
||||||
|
|
||||||
#define INCBIN_STYLE INCBIN_STYLE_SNAKE
|
#define INCBIN_STYLE INCBIN_STYLE_SNAKE
|
||||||
#define INCBIN_PREFIX
|
#define INCBIN_PREFIX
|
||||||
#include <incbin.h>
|
#include <incbin.h>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user