Camera
Generated from engine/render/camera.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.
#include "engine/render/camera.h" · namespace labrador
struct Camera
Section titled “struct Camera”A 2D pan and zoom: what a view's world coordinates have to go through to become screen coordinates. One per view, held by DrawList and applied as each draw is recorded.
A render type and not a mattmath one, because mattmath's contract is that it knows nothing about drawing - and a camera is constructible from a Viewport, which is a render type for the same reason.
translation · scale
Section titled “translation · scale”float scale = 1.0f;Camera
Section titled “Camera”Camera(const Camera&) = default;Camera
Section titled “Camera”constexpr and defined here so DEFAULT_CAMERA is constant-initialised (camera.cpp defines it constinit), and a static in another translation unit that copies it can never read it before it is set.
operator== · operator!=
Section titled “operator== · operator!=”bool operator!=(const Camera& other) const;calculate_view_rectangle
Section titled “calculate_view_rectangle” const mattmath::RectangleF& world_rectangle) const;void calculate_view_rectangle( mattmath::RectangleF& rectangle) const;static mattmath::RectangleF calculate_view_rectangle( const mattmath::RectangleF& world_rectangle,static void calculate_view_rectangle( const mattmath::RectangleF& world_rectangle, const Camera& camera, mattmath::RectangleF& view_rectangle);calculate_intermediate_camera
Section titled “calculate_intermediate_camera” const Camera& first, const Camera& last, float amount);visible_rectangle
Section titled “visible_rectangle”What viewport actually shows of the world under this camera - the inverse of calculate_view_rectangle, and the only inverse this type offers.
The forward transform is view = (world - translation) * scale, so the world extent behind viewport.width pixels is viewport.width / scale. Written by hand, the tempting arithmetic is a MULTIPLY, which is the right arithmetic upside down: it agrees at scale 1, is merely over-inclusive above it, and collapses below it. Camera::frame produces exactly the below-one case whenever a world rectangle is larger than the viewport showing it - framing 6000 world units into 1080 pixels gives scale 0.18, where the multiply reports a visible region 31 times too small in each axis and a cull built on it throws away almost everything on screen.
Throws std::invalid_argument for a zero scale, which is not a viewpoint but a division by nothing. Camera::frame cannot produce one; a hand-built camera can.
The camera that shows all of world_rectangle in viewport.
Both axes are honoured: the scale is whichever of the two ratios fits, and the surplus on the other axis is split evenly so the requested rectangle ends up centred.
Throws std::invalid_argument if either rectangle has a non-positive extent: a zero there is an infinite or a zero scale, which poisons every cull and every draw taken through the result.
calculate_view_position · calculate_view_scale
Section titled “calculate_view_position · calculate_view_scale” const mattmath::Vector2F& world_position) const;float calculate_view_scale(float world_scale) const;DEFAULT_CAMERA
Section titled “DEFAULT_CAMERA”Related types
Section titled “Related types”Named in the public declarations above: RectangleF, Vector2F, Viewport.
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.
tests/render/camera_tests.cpp,null_tests.cpp,pixel_tests.cpptests/scene/cull_tests.cpp,fanout_tests.cpp
Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.