tjammer / raylib-ocaml

OCaml bindings for raylib and raygui
https://tjammer.github.io/raylib-ocaml/
MIT License
173 stars 14 forks source link

Add bindings for rlgl.h #21

Closed Willenbrink closed 2 years ago

Willenbrink commented 2 years ago

Hey, this PR adds bindings for the rlgl.h and ports one example (instanced rendering).

The bindings themselves were mostly made using regexes so it isn't as tidy as the rest of the bindings. I don't really understand how this repository is structured so I've added the relevant files at the most sensible locations. The rlgl bindings reside in their own Rl module and the rl_ prefix of the functions has been removed. Unfortunately rl_begin and rlend include the prefix as begin and end are keywords in OCaml. Perhaps they could be renamed to start/stop, remain as is or we keep the rl prefix everywhere.

I had these unpolished bindings lying around for some time and ported the instanced rendering example when it was still reliant on rlgl. As of now, draw_mesh_instanced is included in the raylib.h so this example is sort of superfluous. It still shows some of the uglier sides of handling carrays and shaders so I guess it's still nice to have.

PS: This PR depends on #20. Is there a nicer way to tell github about this than duplicating the commits from the other PR?

tjammer commented 2 years ago

Thanks for this and sorry for taking a long time to respond!

I think the structuring is fine as it is. At some point I want to separate Math and Rlgl into submodules, so we have to link them only if we need it, but that's a different story. Right now it makes to leave them in the main Raylib module.

As for begin and end, I think it's best to keep the prefix. Maybe we could make it a suffix, so users who search for begin will find begin_rl and don't have to search until they reached r. I'm not really sure which version is best.

Willenbrink commented 2 years ago

Thanks for the feedback and sorry for taking so long to address the issues!

I've made some minor changes to the structure (Rlgl_generated_types is now separate from Raylib_generated_types and no longer a submodule of it), renamed types.ml to raylib_types.ml and addressed the comments.

I've left rl_begin/rl_end with their prefix as I believe that is the most straightforward solution.

tjammer commented 2 years ago

As far as I'm concerned the PR is ready to be merged, thanks!

One more thing: github can't link the commits to your account, thus you don't show up in the contributors list. Is this on purpose? If it's not, feel free to re-push the commits with a fixed author. Although I'm not sure what feature github uses, e-mail maybe.

Willenbrink commented 2 years ago

Oh, that was unintentional. Apparently I never set git up correctly on my current machine. Thanks!