electronstudio / jaylib

Java JNI bindings for Raylib
Other
113 stars 21 forks source link

Utility for swapping Raylib.Vector2 to Jaylib.Vector2 and vice versa #59

Closed MerujSargsyan closed 2 days ago

MerujSargsyan commented 5 days ago

Added a simple utility to do what the title says. May be unnessesary but may cause compilation issues is different vectors are used across projects.

electronstudio commented 5 days ago

Thanks for raising this issue - it does highlight that having the Jaylib.* subclasses causes a lot of confusion for users of the library.

The original reason they were created was that people didn’t like the JavaCPP fluent syntax and wanted traditional constructor methods. So I made those, but they couldn’t go in the auto generated Raylib. classes, so they went in subclasses in Jaylib.. I figured that any time Raylib required a struct as an argument, the user could supply a subclass if he preferred and no other changes would be required.

However if people are finding the need to convert back and forth between the Jaylib. subclasses and and the Raylib. classes then this must have been the wrong approach.

What I’m thinking now is we should eliminate the Jaylib.* stuff completely and instead of having constructors have methods like createCamera() that return a Raylib.Camera.

MerujSargsyan commented 5 days ago

Honeslty, I do think that working on streamlining the process of using only Raylib. instead of having to use both Raylib and Jaylib. within the same file or project would make things much simpler. I believe the go language wrapper manages this by making an object like "Raylib" which can be used to access raylib functions and types.

I will take another look at the other language wrappers to see how they manage this and come up with a better and more clean picture.

electronstudio commented 5 days ago

Jaylib is auto generated using JavaCPP so this limits our ability to create what API we want. Jaylib-FFM is probably more flexible in this regard.

MerujSargsyan commented 5 days ago

Oh in that case where do you think we would place functions such as create camera or create vector? Would this be static or would this be a new class implemented, perhaps called JLib?

Some uses cases would be: JLib.createCamera(...); or JLib.createVector2(x, y)

Or are you picturing something different?

electronstudio commented 4 days ago

This is what I propose: https://github.com/electronstudio/jaylib/pull/62/files

MerujSargsyan commented 2 days ago

I like the proposition and I said more on that open issue specifically. I am going to close this pull request now.