Skip to content

Reading a sprite sheet

Generated from engine/assets/sprite_sheet_loader.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the assets module

#include "engine/assets/sprite_sheet_loader.h" · namespace labrador

std::unique_ptr<SpriteSheet> read_sprite_sheet(const char* json_path,
TextureHandle texture);

Reads the sheet definition at json_path and builds a SpriteSheet drawing from texture. The frame and animation-strip tables are decoded here rather than by SpriteSheet itself, so that nothing on the draw path compiles a JSON parser to draw a sprite.

Throws std::runtime_error naming the path if the file cannot be read or parsed, and naming the path and the offending frame or strip if the document is the wrong shape (T6).

AND FOR ONE THING THE DOCUMENT CAN SAY THAT IS WELL FORMED AND STILL NOT DRAWABLE: a frame with "rotated": true is refused here, by name, rather than loaded and then drawn upright. A sheet is authored content, so a key the engine reads and disagrees with is a worse failure than one it rejects - the .cpp carries the argument, and engine/render/sprite_frame.h is why there is no member to hold the answer.

origin goes the other way: it is honoured, because it costs one addition on a path that already carries an origin (engine/render/sprite_sheet.h).

Named in the public declarations above: SpriteSheet.

The files that include this header directly. A file can also reach it through another header.

Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.