raylib 6 bindings for c3
c3 raylib graphics bindings
0

Configure Feed

Select the types of activity you want to include in your feed.

4 1 0

Clone this repository

https://tangled.org/elliethepuppy.tngl.sh/raylib.c3l https://tangled.org/did:plc:64wgf6irk274ldscrxf5nsby
git@tangled.org:elliethepuppy.tngl.sh/raylib.c3l git@tangled.org:did:plc:64wgf6irk274ldscrxf5nsby

For self-hosted knots, clone URLs may differ based on your setup.



README.md

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:

  1. Clone the repo to wherever you're putting your libraries.
  2. Be sure you have the static raylib 6.0 library.
  3. import raylib6::rl at the top of your program.
  4. When compiling, be sure to include the raylib.c3i file in your lib dir, as well as to -l /path/to/raylib.a AND -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.