ℇbn/notes

2025-03-25T22:38:30

C3: raylib

Now that we covered library packaging, let's see if we can get started with raylib using the C3 raylib package.

Initialize the project

c3c init c3_raylib

Fetching raylib

Use c3c vendor-fetch to fetch raylib and add it as a dependency in project.json.

cd c3_raylib
c3c vendor-fetch raylib55

Assuming c3c version 0.7.0

Using raylib

Edit src/main.c3.

import raylib5::rl;

const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 450;

fn int main()
{
    rl::initWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "C3 raylib");
    rl::setTargetFPS(60);

    while (!rl::windowShouldClose())
    {
        rl::clearBackground(rl::BLACK);

        rl::beginDrawing();

            rl::drawFPS(0, 0);

        rl::endDrawing();
    }

    rl::closeWindow();

    return 0;
}

Running

c3c run

If all goes well you should now see a black window with a fps-meter.

Result (extended example)

alt

full source