Skip to content

Atomvapen/zgui-rl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rlImGui bindings for zig

rlImGui backend for the zgui Dear ImGui bindings

Fork changes

  • Updated comboFromEnum to the lastest Zig version

Getting started

zig fetch --save https://github.com/Atomvapen/zgui-rl/archive/refs/heads/main.tar.gz

Example:

build.zig:

pub fn build(b: *std.Build) void {
    const exe = b.addExecutable(.{ ... });

    const zgui = b.dependency("zgui", .{});
    exe.root_module.addImport("zgui", zgui.module("root"));
    exe.linkLibrary(zgui.artifact("imgui"));

    const rl = b.dependency("raylib-zig", .{});
    exe.root_module.addImport("raylib", rl.module("raylib"));
    exe.linkLibrary(rl.artifact("raylib"));

    b.installArtifact(exe);
    
}

main.zig

const rl = @import("raylib");
const zgui = @import("zgui");

pub fn main() void {
    const screen_width = 1280;
    const screen_height = 800;

    rl.initWindow(screen_width, screen_height, "raylib-Extras [ImGui] example - simple ImGui Demo");
    rl.setTargetFPS(144);
    zgui.rlimgui.setup(true);
    defer zgui.rlimgui.shutdown();

    while (!rl.windowShouldClose()) {
        rl.beginDrawing();
        rl.clearBackground(rl.Color.dark_gray);

        // start ImGui Content
        zgui.rlimgui.begin();

        // show ImGui Content
        var open = true;
        zgui.showDemoWindow(&open);

        // end ImGui Content
        zgui.rlimgui.end();

        rl.endDrawing();
    }
}

Languages

  • C++ 74.0%
  • C 23.1%
  • Zig 2.9%