1 #ifndef DONUT_GRAPHICS_VIEWPORT_HPP
2 #define DONUT_GRAPHICS_VIEWPORT_HPP
32 [[nodiscard]]
static constexpr std::pair<Viewport, int>
createIntegerScaled(ivec2 framebufferSize, ivec2 renderResolution) noexcept {
36 const ivec2 nextViewportSize = renderResolution * (scale + 1);
37 if (nextViewportSize.x > framebufferSize.x || nextViewportSize.y > framebufferSize.y) {
40 result.size = nextViewportSize;
43 result.position = (framebufferSize - result.size) / 2;
44 return {result, scale};
Rectangular region of a framebuffer.
Definition: Viewport.hpp:13
ivec2 size
The width and height of the viewport, in pixels.
Definition: Viewport.hpp:56
ivec2 position
The offset of the viewport, in pixels, from the bottom left of the framebuffer.
Definition: Viewport.hpp:51
static constexpr std::pair< Viewport, int > createIntegerScaled(ivec2 framebufferSize, ivec2 renderResolution) noexcept
Create an integer-scaled viewport that fits into the middle of a framebuffer at the largest positive ...
Definition: Viewport.hpp:32