Skip to content

TextureObject

Generated from engine/render/texture_object.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 render module

#include "engine/render/texture_object.h" · namespace labrador

One still frame out of a sprite sheet.

The frame name is resolved against the sheet once, at construction, and what is kept is a handle: an index into that sheet's frame table. Drawing is then two indexed loads - the sheet out of its registry slot, the frame out of the sheet - with no string touched on the way.

NO CAMERA PARAMETER. The list holds the camera (renderer.h, DrawList::set_camera), so a caller wanting screen space sets nothing and a caller wanting a player's view sets it once for the range rather than passing it down through every signature.

TextureObject() = default;
TextureObject(const std::string& sheet_name,
const std::string& frame_name,
RenderResources* render_resources,
const Colour& color = Colour::white,
float rotation = 0.0f,
SpriteFlip flip = SpriteFlip::none,
float layer_depth = 0.0f);
void set_frame(const std::string& sheet_name,
const std::string& frame_name);
void set_frame(const std::string& frame_name);

Both setters resolve, and the two-argument one moves sheet and frame together because a frame handle taken from one sheet indexes nothing meaningful in another. There is deliberately no way to change the sheet on its own.

It is not atomic: a bad frame name throws with the sheet already moved. That is tolerable only because an unresolvable name is fatal - the worker's exception is rethrown on the joining thread (ThreadPool::wait_for_tasks_to_complete) and the process goes down, so nothing ever draws the mismatched pair.

virtual void draw(DrawList& draw_list,
const mattmath::RectangleF& destination_rectangle) const;
virtual void draw(DrawList& draw_list,
const mattmath::Vector2F& position, float scale = 1.0f) const;
void draw_with(DrawList& draw_list,
const mattmath::RectangleF& destination_rectangle,
const Colour& colour,
const mattmath::Vector2F& origin,
SpriteFlip flip,
float rotation) const;

Draws reading only one per-draw member, layer_depth, which orders nothing on any backend - so callers can compute frame / colour / origin / flip / rotation into locals instead of assigning them to this object first.

A SCENE RUNS draw() ON THE SAME OBJECT FROM EVERY RENDER WORKER AT ONCE, so "set members, then draw" is an unsynchronised data race - and with a std::string element it is concurrent free/allocate on one control block, i.e. heap corruption. The frame is a handle, so passing it costs a register rather than a string copy. The fan-out this describes is engine/scene/scene.cpp's and is pinned by tests/scene/fanout_tests.cpp.

Named in the public declarations above: Colour, DrawList, RectangleF, RenderResources, SpriteFlip, SpriteSheet, SpriteSheetObject, Vector2F.

No sample or test includes this header directly.

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