Open electronstudio opened 6 months ago
C has a problem known as "array to pointer decay". C will automatically convert an array type and to a pointer type. Therefore the computer can't tell if a function parameter is an array of many items or a pointer to a single item. I don't know if modern C has solved this, but Raylib certainly hasn't. The info isn't in raylib_api.json. You just have to read the docs for each function to find out which it is.
So sometimes you will get a Java object that may represent one struct, or may represent an array of structs. You'll need to check the Raylib docs or the Javadoc for the function to know which it has given you.
If it's an array, you can use the getArrayElement() method to access the other structs. To create a new array there is allocateArray() method.
(I suppose we could provide List-like wrappers but to actually make them safe would require working out every function that uses arrays and what parameter it uses to store the size of the array. Nice to have but a luxury that users of C Raylib don't have, and requiring manual maintance work, so out of scope for now.)
Arrays of ints and floats are wrapped as IntBuffer and FloatBuffer. Note if you create your own you should use Raylib.createIntBuffer(1) to ensure you create a direct, native buffer.
It's impossible to tell the difference between an array and a pointer type in raylib.h. Currently (Camera3D *) is special cased to Camera3D, others are MemorySegment.