Appearance
Raylib exporter
Output
Packrat writes one generated C source file and one image per atlas page:
text
atlas.c
atlas.pngThe source contains the atlas page path, frame metadata, initialization, loading, unloading, name lookup, and a draw helper.
Integrate
Compile the generated source with Raylib and keep the images beside the executable or pass their directory to the generated loader:
c
PackratAtlas_atlas atlas;
packrat_atlas_load(&atlas, "assets/atlas");
const PackratAtlas_atlasFrame *frame = packrat_atlas_find("player_0001", -1);
packrat_atlas_draw(&atlas, frame, (Vector2){320, 180}, 0.0f, (Vector2){1, 1}, WHITE);
packrat_atlas_unload(&atlas);Use the actual stem-derived type/function names from the generated file.
Minimal program
For a quick single-file test, include the generated source directly. This assumes the export base name is atlas and the image is beside the executable. Replace player_0001 with a frame name that exists in your atlas:
c
#include "raylib.h"
#include "atlas.c"
int main(void) {
InitWindow(800, 600, "Packrat atlas demo");
PackratAtlas_atlas atlas = {0};
if (!packrat_atlas_load(&atlas, ".")) return 1;
const PackratAtlas_atlasFrame *frame =
packrat_atlas_find("player_0001", -1);
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE);
packrat_atlas_draw(&atlas, frame, (Vector2){400, 300}, 0.0f,
(Vector2){2, 2}, WHITE);
EndDrawing();
}
packrat_atlas_unload(&atlas);
CloseWindow();
return 0;
}For production, compile the generated .c as a normal translation unit and expose the generated declarations through your own project header.