Viewport
Generated from engine/render/viewport.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/viewport.h" · namespace labrador
struct Viewport
Section titled “struct Viewport”A rectangle of the back buffer, plus a depth range, in the shape every graphics API wants it. A render type and not a mattmath one, because mattmath depends on nothing and knows nothing about drawing.
minDepth and maxDepth are camelCase because they mirror D3D11_VIEWPORT's last two fields, which that header spells MinDepth and MaxDepth - so this is the API's name lowered to CONVENTIONS' initial letter rather than the API's name verbatim. The other four are not mirrored at all: this struct says x/y/width/height where D3D11_VIEWPORT says TopLeftX/TopLeftY/Width/ Height.
x · y · width · height · minDepth · maxDepth
Section titled “x · y · width · height · minDepth · maxDepth”float x = 0.0f;float y = 0.0f;float width = 0.0f;float height = 0.0f;float minDepth = 0.0f;float maxDepth = 1.0f;Viewport
Section titled “Viewport”Viewport();Viewport(const Viewport&) = default;Viewport(float x, float y, float width, float height, float minDepth = 0.0f, float maxDepth = 1.0f); float minDepth = 0.0f, float maxDepth = 1.0f); float minDepth = 0.0f, float maxDepth = 1.0f);rectangle · position · size
Section titled “rectangle · position · size”mattmath::Vector2F size() const;pixel_rect
Section titled “pixel_rect”The whole pixels this viewport covers, and THE ONLY CONVERSION TO THEM ANY BACKEND IS ALLOWED TO PERFORM.
EACH EDGE, THEN THE DIFFERENCE, which is the rule sprite_geometry.h's build_sprite_quad already states for a destination rectangle and this is the same question about a bigger one. Truncating the position and the size separately is the obvious alternative and it loses rows: two panes splitting a height of 721 come out 360 and 360 that way, leaving the last row of the back buffer covered by neither, where each-edge-then-the-difference gives 360 and 361 and covers all of it.
IT EXISTS BECAUSE A BACKEND CANNOT BE TRUSTED TO AGREE WITH ITSELF. GL 3.3 core has no float glViewport - glViewportIndexedf is 4.1 - so the GL backend has to make this conversion whatever the seam says. Making it inline and then dividing by the UN-truncated float when building the pixels-to-clip transform has the rasteriser and the projection disagree about how big the viewport is, scaling every sprite in a fractional pane by the ratio between them. One rectangle, computed once, feeds both.
operator=
Section titled “operator=”operator== · operator!=
Section titled “operator== · operator!=”bool operator!=(const Viewport& other) const;Related types
Section titled “Related types”Named in the public declarations above: RectangleF, RectangleI, Vector2F.
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/linesweeper/states/pause_state.cpptests/render/camera_tests.cpp,viewport_tests.cpptests/scene/cull_tests.cpp,fanout_tests.cpp
Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.