On this page
  1. From rmp/assets.h
    1. init
    2. shutdown
    3. using_pack
    4. load_image, load_texture
    5. load_sound
    6. load_font
    7. load_sheet
    8. load_map
    9. load_data
    10. load_value
    11. requested_loads, failed_loads
  2. From rmp/dialogue.h
    1. load_dialogue

rmp::assets

namespace #include <rmp/assets.h> #include <rmp/dialogue.h>

From rmp/assets.h

rmp::assets:: — loading from resources/

init

void init()

Detect and open the resource pack, if there is one, and route raylib's own file loading through it. Called for you by the entry point; calling it twice is harmless.

shutdown

void shutdown()

Release the pack and unhook raylib's loaders. Called for you after your stop hook.

using_pack

bool using_pack()

True when assets are being served from a .rres pack.

load_image, load_texture

rmp::Image load_image(std::string_view name)
rmp::Texture load_texture(std::string_view name)

Load by resource name (e.g. "rabbit.png"). Nothing to unload: the returned value releases itself when the last copy goes, and asking twice for the same name gives you the SAME resource with the reference count at two.

A name that is in neither the pack nor resources/ gives an empty resource rather than a crash, and so does a file that is there and does not decode — a font included: not raylib's built-in one in its place. valid() tells them apart, and drawing an empty one draws nothing — a hole in the picture, not a dead process. Both count in failed_loads().

load_sound

rmp::Sound load_sound(std::string_view name)

The sound device opens on the first call, the same lazy way rmp::audio opens it; on a machine with no device this comes back empty.

load_font

rmp::Font load_font(std::string_view name, int font_size)

font_size is the baked glyph size, and it is part of the cache key: the same font at 16 and at 32 is two resources, because it is two textures. It is 1 to 1024: anything else is an empty font, a failed load and one warning — a negative size aborted inside stb_truetype.

load_sheet

rmp::SpriteSheet load_sheet(std::string_view name)

An .aseprite or .ase from resources/. Every frame is packed into one texture in a single row, so drawing a hundred enemies from the same sheet is one texture bind. Tags, frame ranges and per-frame durations come with it.

On a machine with no GPU the texture is left empty and the metadata is still there, which is what lets tests/animation_test.cpp exist.

load_map

rmp::Tilemap load_map(std::string_view name)
rmp::Tilemap load_map(std::string_view name, std::string_view level)

A level: an LDtk project (.ldtk) or a Tiled map (.json), told apart by the extension. See rmp/tilemap.h for what each editor's conventions mean here, and which of the two is maintained. The tileset images — and an LDtk project's separate level files — are loaded by FILE NAME through the same asset layer, so they come out of resources.rres in a release and out of resources/ while developing without the map knowing which.

level picks an LDtk level by its identifier; without it, the first level. Tiled maps have one level and ignore it.

Returns an empty map and says why if it cannot be read: map = rmp::assets::load_map("world.ldtk");

load_data

std::vector<unsigned char> load_data(std::string_view name)

The bytes of a file — a level, a shader's source, JSON, anything whose meaning only the caller knows — as a vector that frees itself. Not cached: every call reads the file again. Empty when the name is in neither the pack nor resources/.

Empty when it is not there

load_value

rmp::Value load_value(std::string_view name)

A JSON file — tuning numbers, a table of items, dialogue — read into an rmp::Value, which remembers its file: while a Debug build runs on the desktop, if (tuning.changed()) tuning.reload(); picks up an edit made in any text editor (rmp::Value::changed() says how). An empty Value, said once, when the file is not there or is not JSON. Include rmp/save.h to use it:

#include <rmp/save.h>
static rmp::Value tuning = rmp::assets::load_value("tuning.json");

requested_loads, failed_loads

int requested_loads()
int failed_loads()

How many rmp::assets:: loads were asked for, and how many gave nothing usable: nothing in the pack and nothing on disk, or a file that is there and does not decode. The entry point reports these to the CI boot gate; you are unlikely to need them yourself.

From rmp/dialogue.h

rmp::Dialogue — conversations written in Yarn Spinner 3.

load_dialogue

Dialogue load_dialogue(std::string_view file)
Dialogue load_dialogue(std::span<const std::string_view> files)

A .yarn file of resources/, compiled. Its errors, if any, are in errors(), said in the log and, in a debug build, on screen.