Skip to content

tiawl/cimgui.zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cimgui.zig

This is a fork of ocornut/imgui packaged for Zig

Why this fork ?

The intention under this fork is to package ocornut/imgui for Zig. So:

How to use it

The goal of this repository is not to provide a Zig binding for ocornut/imgui. There are at least as many legit ways as possible to make a binding as there are active accounts on Github. So you are not going to find an answer for this question here. The point of this repository is to abstract the ocornut/imgui compilation process with Zig (which is not new comers friendly and not easy to maintain) to let you focus on your application. So you can use cimgui.zig:

cimgui.zig as a library

If you want to add cimgui.zig as a library to your project, you can do the following (do know that it requires a zig version >0.13) :

Fetch this repository :

$ zig fetch --save git+https://github.com/tiawl/cimgui.zig

Add it to your build.zig :

const std = @import("std");
+const cimgui = @import("cimgui.zig");

pub fn build(b: *std.Build) void {
    // -- snip --

+    const cimgui_dep = b.dependency("cimgui.zig", .{
+        .target = target,
+        .optimize = optimize,
+        .platform = cimgui.Platform.GLFW,
+        .renderer = cimgui.Renderer.Vulkan,
+    });

    // Where `exe` represents your executable/library to link to
+    exe.linkLibrary(cimgui_dep.artifact("cimgui"));

    // -- snip --
}

And that's it ! You're ready to go ! See the examples directory on how to move forward from there.

Backends

The backends are separated in two categories : the platforms (handling windows, events, ...) and the renderers (draw to screen, ..).

Platform

Renderers

As you can see, these backends do not support all of those supported by ImGUI. Adding a backend is a bit of work because of the needed maintenance. Please do not ask for backends to be added if you don't feel like adding them yourselves !

Dependencies

The Zig part of this package is relying on the latest Zig release (0.13.0) and will only be updated for the next one (so for the 0.14.0).

Here the repositories' version used by this fork:

Currently there are no tags/release for dearimgui/dear_bindings so cimgui.zig is relying on the last commit.

For backends see the build.zig.zon

CICD reminder

These repositories are automatically updated when a new release is available:

This repository is automatically updated when a new release is available from these repositories:

zig build options

These additional options have been implemented for maintainability tasks:

  -Dfetch=[bool]               Update .references folder and build.zig.zon then stop execution
  -Dupdate=[bool]              Update binding
  -Drenderer=[enum]            Specify the renderer backend
                                 Supported Values:
                                   Vulkan
                                   OpenGL3
  -Dplatform=[enum]            Specify the platform backend
                                 Supported Values:
                                   GLFW
                                   SDL3

License

This repository is not subject to a unique License:

The parts of this repository originated from this repository are dedicated to the public domain. See the LICENSE file for more details.

For other parts, it is subject to the License restrictions their respective owners choosed. By design, the public domain code is incompatible with the License notion. In this case, the License prevails. So if you have any doubt about a file property, open an issue.