Skip to content

Reading a sprite sheet

Generated from engine/assets/sprite_sheet_loader.h at 0f4f503. 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

Audience: game code.

#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 or has an unknown key (T6). This includes nested position, size, origin and first-frame objects; unsupported fields must be removed or corrected instead of being silently ignored. A negative animation-strip frame_count throws std::runtime_error naming the path, strip and field. Zero frames define an empty strip. An unrepresentable cached strip x coordinate throws std::runtime_error naming the path, strip and frame coordinate.

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.

No guide or concept page links to this header yet.

Documentation for Labrador v0.3.0. Built from Labrador 0f4f503 of 2026-11-03.

All documentation versions