ResourceLoader
Generated from engine/assets/resource_loader.h at aceb130. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.
Audience: game code.
#include "engine/assets/resource_loader.h" · namespace labrador
class ResourceLoader
Section titled “class ResourceLoader”Turns a manifest into loaded resources, and does it again when the GPU throws the first set away.
Its built-in kinds load textures, fonts, sprite sheets, XWB sound banks and single-WAV banks. The manifest chooses which ones a game has (T7). A game registers another kind rather than teaching the engine that game's vocabulary (T1).
LoadAsset
Section titled “LoadAsset”using LoadAsset = std::function<void(const std::string& directory, const std::string& name, bool optional)>;Builds one asset from a manifest entry. A kind owns its own file naming, extension included, which is why this is handed the directory and the name rather than a finished path. optional is the manifest's own word for "the game still runs without this" (asset_manifest.h). A kind that has no substitute to offer ignores it and throws; the audio kinds offer a silent bank.
AssetKind
Section titled “AssetKind”{ LoadAsset load; LoadAsset reload_device;};A kind of asset, and what a device loss does to it. reload_device runs in place of load on a device restore; leave it empty for a kind the GPU does not hold - a sound bank, a level definition - and the restore skips it, which is what keeps borrowed pointers into those alive.
It is a second function rather than a flag because rebuilding is not always re-loading: a sprite sheet's device half is its texture, and the frame and strip tables that every handle indexes into are not rebuilt at all.
THE CRITERION IS WHAT THE GPU HOLDS, NEVER WHETHER THIS BUILD'S BACKEND CAN LOSE A DEVICE. Two configurations never call reload_device at all - the null backend has nothing to lose, and gl on Windows has a WGL context, which is not lost - so a game written and run against either can leave every one of these empty and watch nothing go wrong. The same gl/ in a browser does call it, once the browser hands back a WebGL2 context it took away. It is the same source a Direct3D build compiles: LABRADOR_RENDER_BACKEND picks the backend at configure time (T5), so what varies is which build ever runs this function, not which source has to write it. engine/render/SEAM.md#8 carries the argument, and tests/assets/resource_loader_tests.cpp pins what a restore does with what is written here.
Declared as ResourceLoader::AssetKind.
ResourceLoader
Section titled “ResourceLoader”The stores to fill are handed in - the loader fills stores, it does not own them.
The renderer rather than a device, and this file names no graphics type as a result: the two kinds that need one go through engine/render/resource_factory.h, which reads the device off the renderer at the moment it builds. A device restore hands back a different device, and a loader that held one would have to be re-seated from on_device_restored; read at build time, there is nothing for a caller to re-seat. The audio device rather than a library's engine object, and for the same reason: this file names no audio API, so a client that loads an asset does not compile one. Which audio API is behind engine/audio/audio_device.h is chosen in CMake and named nowhere above it.
ResourceLoader · operator=
Section titled “ResourceLoader · operator=”ResourceLoader& operator=(const ResourceLoader&) = delete;The built-in kinds hold this, so a copy would quietly load into the original's stores.
register_kind
Section titled “register_kind”Teaches the loader a kind of asset a manifest may name. The engine registers "texture", "font", "sprite_sheet", "sound_bank" and "wave" at construction; anything else is the game's to register, before it loads a manifest that names one. Registering a kind twice replaces it.
load_manifest
Section titled “load_manifest”Loads every asset the manifest names, in the order it names them, and keeps the manifest so that a device restore can replay it. A second manifest replaces the first as the thing a restore replays, so a game with more than one loads them as one.
Throws std::out_of_range naming the kind, the asset and the manifest file if an entry names a kind nobody registered - which is a content bug, and this is the line that should report it (T6). Whatever loaded before the bad entry stays loaded; the manifest is not kept. An unavailable optional sound bank or WAV reports through diagnostic.h and substitutes SoundBank::silent(); required audio errors still throw. A "wave" asset reads directory/name.wav into a one-wave bank; the bank, wave and persistent effect all use the manifest's name. Its missing, malformed, unsupported or unplayable optional container may use that substitute; allocation failures and logic errors propagate.
reload_device_resources
Section titled “reload_device_resources”void reload_device_resources();Rebuilds what lives on the GPU after a device loss, by walking the same manifest again. Replaying the same names is the load-bearing part: drawables hold handles to registry slots and a slot belongs to a name, so a rebuild producing the same *count* under different names would leave every handle reading the wrong resource. Walking the manifest makes that true by construction, where a second list kept in step by hand only makes it true today.
Kinds with no reload_device are skipped: they are not device resources, and callers hold borrowed SoundBank* and level-definition pointers into them that a reload would invalidate. Sprite-sheet definitions are retained, not reparsed or revalidated. A replacement atlas must still contain every retained frame and strip.
Related types
Section titled “Related types”Named in the public declarations above: AssetKind, AssetManifest, AudioDevice, AudioResources, RenderResources, Renderer.
In the samples and tests
Section titled “In the samples and tests”The files that include this header directly. A file can also reach it through another header.
samples/audio/smoke_test.cpp,sound_board_tests.cppsamples/components/animation_preview_null_tests.cpptests/assets/grid_sheet_loader_tests.cpp,resource_loader_tests.cpp,sprite_sheet_resource_tests.cpp,wave_asset_tests.cpp
Explained in
Section titled “Explained in”Development documentation (unreleased). Built from Labrador aceb130 of 2026-11-20.