Not-Nik / raylib-zig

Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib
MIT License
473 stars 101 forks source link

work in progress: Add raygui support #39

Closed jdoleary closed 11 months ago

jdoleary commented 1 year ago

This isn't working yet, but I'm definitely getting close.

When I run zig build raygui_button I get the following error:

error: lld-link: undefined symbol: GuiButton

I'm uploading this PR to reference in Issue: https://github.com/Not-Nik/raylib-zig/issues/38

I'm using zig-windows-x86_64-0.10.1

jdoleary commented 1 year ago

More progress. Turns out the header file is actually being imported correctly. When I add a simple function to the top of the raygui header and then call it in zig it works. So that tells me that somehow the other raygui functions I'm attempting to call are not defined! The exploration continues...

jdoleary commented 1 year ago

Okay I think I figured it out. to.defineCMacroRaw("RAYGUI_IMPLEMENTATION"); in lib.zig isn't actually defining RAYGUI_IMPLEMENTATION in the header file.

The build.zig file is outputting this: --pkg-begin raygui C:\git\raylib-zig-experiments\lib\raygui-zig.zig --pkg-end -D RAYGUI_IMPLEMENTATION so I think maybe I somehow have the macro defined in the wrong place, maybe it needs to be a part of a compile step or something.

jdoleary commented 1 year ago

I fixed it by changing build.zig with the following: raygui.defineCMacroRaw("RAYGUI_IMPLEMENTATION"); Now it is a part of the "raygui" step. However I am now getting a raylib/raygui specific error

error: lld-link: undefined symbol: GetCodepointNext
>>> referenced by raygui.lib(raygui.obj):(GetTextWidth)
>>> referenced by raygui.lib(raygui.obj):(GuiDrawText)
>>> referenced by raygui.lib(raygui.obj):(GuiTextBox)
>>> referenced 1 more times

Which I think it due to it not properly importing raylib (since raylib defines GetCodepointNext). I will continue to investigate.

jdoleary commented 1 year ago

Turns out I was using raygui v3.5-dev which expects raylib v4.5-dev

Not-Nik commented 1 year ago

Is this ready to merge?

raysan5 commented 1 year ago

It should probably be updated for raygui 4.0-dev, the API design changed to be more consistent, coherent and extendable.

jdoleary commented 1 year ago

No, I got stuck trying to get raygui added to the build and ran out of free time to work on it. I got it really close but couldn’t get the last but working

On Mon, Jul 3, 2023 at 12:45 PM Nikolas @.***> wrote:

Is this ready to merge?

— Reply to this email directly, view it on GitHub https://github.com/Not-Nik/raylib-zig/pull/39#issuecomment-1618873770, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQ5YBPQ35ISKHV256IGIB3XOLZMLANCNFSM6AAAAAAWMLO7KU . You are receiving this because you authored the thread.Message ID: @.***>

jdoleary commented 11 months ago

@raysan5 Didn't see your comment, I'm not going to continue with zig until the language is more complete. I've had a hell of a time finding documentation about how build.zig works. I even tried looking through the source but couldn't resolve my issue. I may return to it later but for now I'll close this.