1#ifndef LIBSBX_GRAPHICS_VIEWPORT_HPP_
2#define LIBSBX_GRAPHICS_VIEWPORT_HPP_
6#include <libsbx/utility/enum.hpp>
8#include <libsbx/math/vector2.hpp>
10namespace sbx::graphics {
16 enum class type : std::uint8_t {
17 fixed = utility::bit_v<0>,
18 window = utility::bit_v<1>,
19 dynamic = utility::bit_v<2>,
20 all = fixed | window | dynamic
27 static auto fixed(
const std::uint32_t width,
const std::uint32_t height) ->
viewport {
55 auto size()
const noexcept ->
const std::optional<math::vector2u>& {
63 auto is_fixed()
const noexcept ->
bool {
64 return _type == type::fixed;
67 auto is_window()
const noexcept ->
bool {
68 return _type == type::window;
71 auto is_dynamic()
const noexcept ->
bool {
72 return _type == type::dynamic;
75 auto is_type(
const type flags)
const noexcept ->
bool {
76 return utility::to_underlying(flags) & utility::to_underlying(_type);
90 std::optional<math::vector2u> _size;
94inline constexpr auto operator|(
const viewport::type lhs,
const viewport::type rhs)
noexcept -> viewport::type {
95 return utility::from_underlying<viewport::type>(utility::to_underlying(lhs) | utility::to_underlying(rhs));
105 _aspect_ratio{
static_cast<std::float_t
>(extent.x()) /
static_cast<std::float_t
>(extent.y())} { }
107 auto operator==(
const render_area& other)
const noexcept ->
bool {
108 return _extent == other._extent && _offset == other._offset;
127 auto aspect_ratio()
const noexcept -> std::float_t {
128 return _aspect_ratio;
131 auto set_aspect_ratio(std::float_t aspect_ratio)
noexcept ->
void {
132 _aspect_ratio = aspect_ratio;
139 std::float_t _aspect_ratio;
Definition: viewport.hpp:98
Definition: viewport.hpp:12
A vector in two-dimensional space.
Definition: vector2.hpp:27