Raylib6 bindings for C3#
I'm doing this as a little exercise in both learning to write bindings and learning raylib. These bindings aren't guaranteed to be perfect, but they work.
Using the library#
To be honest, C3's build system fucking sucks. If you know how to do this that way, then you know. I don't lol. Here's how i'd do it:
- Clone the repo to wherever you're putting your libraries.
- Be sure you have the static raylib 6.0 library.
import raylib6::rlat the top of your program.- When compiling, be sure to include the
raylib.c3ifile in your lib dir, as well as to-l /path/to/raylib.aAND-l X11. for example:$ c3c compile src/main.c3 lib/raylib.c3l/raylib.c3i -l ./lib/raylib/raylib.a -l X11 -o build/main.
Small example:#
import raylib6::rl;
// Returns a random `Color` using Raylib's built-in random functions.
fn Color random_color()
{
return {(char)rl::get_random_value(0, 255), (char)rl::get_random_value(0, 255), (char)rl::get_random_value(0, 255), 255};
}
fn void main()
{
rl::init_window(800, 600, "white noise demo");
while (!rl::window_should_close) {
rl::begin_drawing();
for (int i = 0; i < 800; i++) {
for (int j = 0; j < 600; j++) {
rl::draw_pixel(i, j, random_color());
}
}
rl::end_drawing();
}
}
Then run c3c compile-run src/main.c3 /path/to/raylib.c3i -l /path/to/raylib.a -l X11 -o /where/you/want/the/output/whitenoise and you should see something that looks like tv static.