libdonut  2.3.2
Application framework for cross-platform game development in C++20
Static Public Member Functions | Public Attributes | List of all members
donut::graphics::Viewport Struct Reference

Rectangular region of a framebuffer. More...

#include <donut/graphics/Viewport.hpp>

Static Public Member Functions

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 integer scale of an original render resolution that still fits within the framebuffer. More...
 

Public Attributes

ivec2 position
 The offset of the viewport, in pixels, from the bottom left of the framebuffer. More...
 
ivec2 size
 The width and height of the viewport, in pixels. More...
 

Detailed Description

Rectangular region of a framebuffer.

Examples
example_game.cpp, and example_rectangle.cpp.

Member Function Documentation

◆ createIntegerScaled()

static constexpr std::pair<Viewport, int> donut::graphics::Viewport::createIntegerScaled ( ivec2  framebufferSize,
ivec2  renderResolution 
)
inlinestaticconstexprnoexcept

Create an integer-scaled viewport that fits into the middle of a framebuffer at the largest positive integer scale of an original render resolution that still fits within the framebuffer.

Parameters
framebufferSizethe size of the framebuffer to fit the viewport into, in pixels.
renderResolutionthe original rendered size to be scaled into the framebuffer, in pixels.
Returns
a pair where:
  • the first element contains the new scaled viewport, and
  • the second element contains the integer scale that was chosen.
Note
If the original render resolution cannot fit within the framebuffer, then a viewport with the original render resolution will be returned along with a scale of 1.
Examples
example_game.cpp.

Member Data Documentation

◆ position

ivec2 donut::graphics::Viewport::position

The offset of the viewport, in pixels, from the bottom left of the framebuffer.

◆ size

ivec2 donut::graphics::Viewport::size

The width and height of the viewport, in pixels.


The documentation for this struct was generated from the following file: