Zig-ImGui
Zig-ImGui copied to clipboard
Update for zig 0.10.0
Changes:
- Update function pointers
-
fastmod -e zig '\?fn' '?*const fn'
-
fastmod -e zig '= fn' '= *const fn'
-
- Fix some errors trying to print
?[*:0]u8
by printing "" if the value is null
- Replace
std.builtin.TypeInfo
withstd.builtin.Type
-
CallingConvention
appears to be part ofstd.builtin
, not@import("builtin")
- Replace
@bitCast
with@enumToInt
There's one hack in there because of some new alignment rules that I'm not sure how to avoid:
- Change DrawCallback_ResetRenderState to be
~3
instead of~0
because of alignment errors I'm not sure this is the correct approach, but the constant should be used by all the in tree examples
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.
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,
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 %
yeah it definitely looks like that issue. I am not entirely sure about the alignment issue, though. That's even more obscure to me.
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. :)