Viewport
Viewports are extensions of windows that allow restricting rendering to a specific area of the screen.
Overview
Viewports are represented by the Window::Viewport structure. They allow delimiting the rendering zone to a defined portion of a window.
By default, every object is rendered within the global viewport of the window, whose origin is the top-left corner:
Viewports allow restricting this area to a defined portion:
Their constructor is as follows:
zone— rendering area of the viewportcamera— camera attached to the viewport
In this section, only the constructor taking an Area parameter will be covered.
Camera usage will be addressed in the tilemap section.
Usage
Viewports are created and managed through the following Window methods:
void addViewport(std::string_view tag, Viewport vp) noexcept; // register a named viewport
void removeViewport(std::string_view tag) noexcept; // delete a named viewport
void useViewport(std::string_view tag) noexcept; // activate a viewport for subsequent draws
void resetViewport(void) noexcept; // restore the default full-window viewport
tag— unique identifier of the viewport
For example:
rmk::Window win;
rmk::Rectangle rect(0, 200); // position (0, 0) — size 200x200
rmk::Window::Viewport vp(rmk::Area(500, 100, 100, 100));
win.addViewport("view", vp);
win.fill(rect, rmk::color::red);
win.fill(rect, rmk::color::cyan, "view");

The useViewport method sets a default active viewport, used when no identifier
is passed to the window's rendering methods. resetViewport deactivates it
and restores the global viewport.