SpexGuy / Zig-ImGui

Zig bindings for ocornut/imgui, generated using cimgui/cimgui
MIT License
92 stars 20 forks source link

Update for zig 0.10.0 #10

Open ryansname opened 1 year ago

ryansname commented 1 year ago

Changes:

There's one hack in there because of some new alignment rules that I'm not sure how to avoid:

It is also currently unable to run zig build test due to the below error which I haven't traced yet either:

/Users/ryan/Documents/code/Zig-ImGui/zig-imgui/imgui.zig:446:5: error: dependency loop detected
pub const DrawCallback = ?*const fn (parent_list: ?*const DrawList, cmd: ?*const DrawCmd) callconv(.C) void;
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    DrawCmd: /Users/ryan/Documents/code/Zig-ImGui/zig-imgui/imgui.zig:1831:28
    DrawList: /Users/ryan/Documents/code/Zig-ImGui/zig-imgui/imgui.zig:1884:23
    DrawList: /Users/ryan/Documents/code/Zig-ImGui/zig-imgui/imgui.zig:1883:29
    DrawCallback: /Users/ryan/Documents/code/Zig-ImGui/zig-imgui/imgui.zig:446:59
    DrawCmd: /Users/ryan/Documents/code/Zig-ImGui/zig-imgui/imgui.zig:1837:19

I am able to run the GLFW example locally, but do not have the Vulkan libraries handy to test that, it compiles but fails to link.

I also was able to use the GLFW example in my local project.

tanis2000 commented 1 year ago

That circular dependency loop is a good question. Did you manage to wrap your head around it?

I would suggest to try replacing line 1834 in imgui.zig with

UserCallback: ?*anyopaque,
ryansname commented 1 year ago

Oh yeah, thanks for the prompt, looks like it might be ziglang/zig#12325. If I run the tests as zig build test -fstage1 it succeeds, though I have to re-hack that pointer from ~3 to ~7

Zig-ImGui % zig build test -fstage1
All 4 tests passed.
Zig-ImGui % zig version
0.10.0
Zig-ImGui % 
tanis2000 commented 1 year ago

yeah it definitely looks like that issue. I am not entirely sure about the alignment issue, though. That's even more obscure to me.

nurpax commented 1 year ago

Thanks for publishing this PR, @ryansname! I took this change and updated it to imgui 1.89.4 and updated the bindings here: https://github.com/nurpax/zig-imgui

This adds a sokol gfx backend which is handy for my own projects, thought I'd share the imgui parts for anyone who cares. :)