As I already commented in another post, I am working on some bindings for raylib. I open this one in order to have a dedicated thread for it.
It should be noted that my experience in Ada is limited, and believe that I have made some unwise decisions. Hopefully someone can bring some of them up
.
For now, I have binded:
rcore(windowing & input & timing & etc)rcamerarshapesrtext(partially)
Design notes
I have chosen to split the library into packages as follows:
Types and conversions ā Raylib.Types ( conversions are To_C and To_Ada )
Function bindings ā Raylib.{Window,Draw,Time,Camera,Shapes,Text}
Many conversions are mostly just direct and provided for uniformity. The remaining ones are just for converting between types.
Where a const char * was received, I changed them to take String and the use Interfaces.C.Strings.New_String and Interfaces.C.Strings.Free to convert to a C string.
One that I am concerned about is on functions that take a pointer to the first of several elements. e.g Raylib.Shapes.Check_Collision_Point_Poly.
I have modeled it this way:
---- Raylib.Types
--
-- Polygon[3D] - Set of points representing a polygon
--
type Polygon is array (Natural range <>) of aliased Point
with Convention => C;
type Polygon3D is array (Natural range <>) of aliased Point3D
with Convention => C;
---- Raylib.Shapes
function Check_Collision_Point_Poly
(Point : Vector2;
Poly : Polygon) return Boolean is
function CheckCollisionPointPoly
(point : Vector2;
points : access constant Vector2;
pointCount : Int) return Bool;
pragma Import (C, CheckCollisionPointPoly, "CheckCollisionPointPoly");
begin
return To_Ada (CheckCollisionPointPoly (Point,
Poly(Poly'First)'Access,
Int (Poly'Length)));
end Check_Collision_Point_Poly;
Roadmap
The bindings should be close to ready for use in basic 2D games. If anyone would like to give some feedback or contribute, it would be much appreciated.
This are some steps in the roadmap:
- Add a Math module equivalent to raymath
- Add support for more modules
- Package for alire (for this one a more experience hand would really help)
Repository
As a final note, I have used some generative AI for generating some bindings, but its use has been limited to basically copy-pasting and trivial changes