Not-Nik / raylib-zig

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

Adding support for raygui #95

Closed mohanavel15 closed 4 months ago

mohanavel15 commented 4 months ago

Hello, I'm trying add support for raygui.

As of now i have just updated build.zig & generate_functions.py files. Seems it requires manually generated prelude files. I'm not sure how to do that. Please let me know how to continue from here.

mohanavel15 commented 4 months ago

is preludes files are zig c translated and manually refactored?

Not-Nik commented 4 months ago

The prelude files should include all of the types defined by raygui. This can be done by adjusting output of translate-c or manually creating the types, whatever you like best. Alternatively I could also look into this in the coming days when I have some time

mohanavel15 commented 4 months ago

cool. Seems like translate-c then modifying is more work than manually coding so I'm manually doing them.

mohanavel15 commented 4 months ago

Hey, it would be really helpful if you could explain how each file is created. Is the prelude file for type definitions, and are the files generated by the Python script just copies of the prelude? So, am I supposed to implement the logic in Zig on top of the generated files, or should I do something else? If I have to modify the generated files, am I supposed to implement the whole thing or just function definitions and 'extern "C"'? seems like i should 'extern "c"' the implementation.

Not-Nik commented 4 months ago

The python scripts defines the external c functions and aliases them to fit in with zigs naming conventions, nothing else. The main preludes are mainly used to define types (i.e. structs and enums) and as of lately also overwrite some of the aliases to provide a cleaner interface when dealing with pointers and arrays/slices. The ext preludes are pretty much only there for imports, so that these don't have to be hardcoded in the script

mohanavel15 commented 4 months ago

gotcha. modifying the python file to getting it to generate for raygui.

mohanavel15 commented 4 months ago

I'm mostly done just ran into a problem which I'm not sure how to handle. parameter name text used in raylib only as const char *text but few in raygui uses it as const char **text. so causing error in ziggify_type function. if add text to multi = [...] list then it causes side effect on const char *text.

Will commit the code shortly.