2#ifndef LIBSBX_GRAPHICS_VIEWPORT_HPP_
3#define LIBSBX_GRAPHICS_VIEWPORT_HPP_
7#include <libsbx/utility/enum.hpp>
9#include <libsbx/math/vector2.hpp>
11namespace sbx::graphics {
17 enum class type : std::uint8_t {
18 fixed = utility::bit_v<0>,
19 window = utility::bit_v<1>,
20 dynamic = utility::bit_v<2>,
21 all = fixed | window | dynamic
28 static auto fixed(
const std::uint32_t width,
const std::uint32_t height) ->
viewport {
56 auto size()
const noexcept ->
const std::optional<math::vector2u>& {
64 auto is_fixed()
const noexcept ->
bool {
65 return _type == type::fixed;
68 auto is_window()
const noexcept ->
bool {
69 return _type == type::window;
72 auto is_dynamic()
const noexcept ->
bool {
73 return _type == type::dynamic;
76 auto is_type(
const type flags)
const noexcept ->
bool {
77 return utility::to_underlying(flags) & utility::to_underlying(_type);
91 std::optional<math::vector2u> _size;
95inline constexpr auto operator|(
const viewport::type lhs,
const viewport::type rhs)
noexcept -> viewport::type {
96 return utility::from_underlying<viewport::type>(utility::to_underlying(lhs) | utility::to_underlying(rhs));
106 _aspect_ratio{
static_cast<std::float_t
>(extent.x()) /
static_cast<std::float_t
>(extent.y())} { }
108 auto operator==(
const render_area& other)
const noexcept ->
bool {
109 return _extent == other._extent && _offset == other._offset;
128 auto aspect_ratio()
const noexcept -> std::float_t {
129 return _aspect_ratio;
132 auto set_aspect_ratio(std::float_t aspect_ratio)
noexcept ->
void {
133 _aspect_ratio = aspect_ratio;
140 std::float_t _aspect_ratio;
Definition: viewport.hpp:99
Definition: viewport.hpp:13
A vector in two-dimensional space.
Definition: vector2.hpp:28