-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontext_settings.hpp
133 lines (107 loc) · 5.05 KB
/
context_settings.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef SYSTEM_CONTEXT_SETTINGS_HPP
#define SYSTEM_CONTEXT_SETTINGS_HPP
#include <limits>
#include <common/version.hpp>
namespace framework::system
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @addtogroup system_graphic_context
/// @{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Graphic context settings.
///
/// Structure to store context settings. Used by the @ref framework::system::window class to setup graphic context.
/// Context is always double-buffered and always RGB-capable.
/// After the context is created, the values in the ContextSettings are updated to the actual ones.
/// If the any value is set to `dont_care`, this parameter is not taken into account when creating the context.
/// Otherwise, the closest to the specified value is selected.
class ContextSettings
{
public:
static constexpr std::uint32_t default_max_depth_bits = 24;
static constexpr std::uint32_t default_max_stencil_bits = 8;
static constexpr std::uint32_t best = 999;
static constexpr std::uint32_t dont_care = 0;
ContextSettings() = default;
ContextSettings(const ContextSettings&) = default;
ContextSettings(ContextSettings&&) = default;
~ContextSettings() = default;
ContextSettings& operator=(const ContextSettings&) noexcept = default;
ContextSettings& operator=(ContextSettings&&) noexcept = default;
#pragma region setters
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @name setters
/// @{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets required API version.
///
/// @param version required version.
///
/// @return Reference to context settings.
ContextSettings& version(Version version);
/// @brief Sets depth buffers bits count.
///
/// @param bits Depth buffer bits count.
///
/// @return Reference to context settings.
ContextSettings& depth_bits(std::uint32_t bits);
/// @brief Sets stencil buffer bits count.
///
/// @param bits Stencil buffer bits count.
///
/// @return Reference to context settings.
ContextSettings& stencil_bits(std::uint32_t bits);
/// @brief Sets the semples count for multisampling (antialiasing).
///
/// @param samples The number of samples per pixel.
///
/// @return Reference to context settings.
ContextSettings& samples_count(std::uint32_t samples);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma endregion
#pragma region getters
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @name getters
/// @{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/// @brief API version.
///
/// @return Required API version.
////////////////////////////////////////////////////////////////////////////
Version version() const;
////////////////////////////////////////////////////////////////////////////
/// @brief Detph buffer bits count.
///
/// @return The detph buffer bits count.
////////////////////////////////////////////////////////////////////////////
std::uint32_t depth_bits() const;
////////////////////////////////////////////////////////////////////////////
/// @brief Stencil buffer bits count.
///
/// @return The stencil buffer bits count.
////////////////////////////////////////////////////////////////////////////
std::uint32_t stencil_bits() const;
////////////////////////////////////////////////////////////////////////////
/// @brief Samples count.
///
/// @return The number of samples per pixel.
////////////////////////////////////////////////////////////////////////////
std::uint32_t samples_count() const;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma endregion
private:
std::uint32_t m_depth_bits = best;
std::uint32_t m_stencil_bits = best;
std::uint32_t m_samples_count = best;
Version m_version = {3, 2};
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} // namespace framework::system
#endif