Re: Raylib and Classes
- Posted by ghaberek (admin) Aug 27, 2022
- 865 views
Icy_Viking said...
typedef struct Vector2 { float x; // Vector x component float y; // Vector y component } Vector2; typedef struct Color { unsigned char r; // Color red value unsigned char g; // Color green value unsigned char b; // Color blue value unsigned char a; // Color alpha value } Color; RLAPI void DrawPixelV(Vector2 position, Color color);
I'm a bit confused on how to use it with DLL functions.
A lot of Raylib functions pass structures by value instead of by pointer. You can get around this by "expanding" the structure members as parameters. But there's not much you can do about returning structure by value since Euphoria doesn't support that at this time. This is why I made raylibshim which accepts and returns structures by pointer instead. (Apparently I need to update raylibshim for version 4.0.) I can't help you with this classes library per se but here's how you would expand the structure members.
constant xDrawPixelV = define_c_proc(ray,"DrawPixelV",{ C_FLOAT, -- position.X C_FLOAT, -- position.Y C_UCHAR, -- color.r C_UCHAR, -- color.g C_UCHAR, -- color.b C_UCHAR -- color.a }) public procedure DrawPixelV(sequence position, sequence color) c_proc(xDrawPixelV,{ position[1], -- float position[2], -- float color[1], -- unsigned char color[2], -- unsigned char color[3], -- unsigned char color[4] -- unsigned char }) end procedure
-Greg