Go to the documentation of this file.
9 #ifndef EAGINE_APPLICATION_OPTIONS_HPP
10 #define EAGINE_APPLICATION_OPTIONS_HPP
12 #include "../main_ctx_object.hpp"
13 #include "../string_span.hpp"
14 #include "../valid_if/between.hpp"
15 #include "../valid_if/nonnegative.hpp"
16 #include "../valid_if/not_empty.hpp"
17 #include "../valid_if/not_equal.hpp"
18 #include "../valid_if/one_of.hpp"
19 #include "../valid_if/positive.hpp"
54 _provider_name = std::move(name);
61 return !
extract(_provider_name).empty();
67 return are_equal(
string_view(_provider_name), name);
72 return {_provider_name};
80 return {_display_name};
88 return {_driver_name};
96 return {_device_path};
106 return {_device_kind};
133 return {_gl_version_major};
140 return {_gl_version_minor};
147 return _gl_compat_context;
153 return _gl_debug_context;
159 return _gl_robust_access;
168 _surface_width =
extract(width);
169 _surface_height =
extract(height);
176 return {_surface_width};
182 return {_surface_height};
221 return {_color_bits};
247 return {_alpha_bits};
272 return {_depth_bits};
283 _stencil_bits =
extract(value);
297 return {_stencil_bits};
303 if((_offscreen = value)) {
315 auto needs_offscreen_framebuffer() const noexcept ->
bool {
316 return _offscreen_framebuffer;
322 if((_fullscreen = value)) {
336 return {_framedump_prefix};
341 return _framedump_color;
346 return _framedump_depth;
351 return _framedump_stencil;
498 _requires_input =
false;
506 _requires_input =
true;
512 return _requires_input;
516 template <
typename R,
typename P>
519 return _max_run_time &&
extract(_max_run_time) <= run_time;
524 return _max_frames &&
extract(_max_frames) <= frame_no;
530 std::string _app_title;
532 std::map<identifier, video_options> _video_opts;
533 std::map<identifier, audio_options> _audio_opts;
537 bool _requires_input{
false};
542 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
543 #include <eagine/application/options.inl>
Application harness / wrapper code is placed in this namespace.
Definition: eagine.hpp:72
Helper class used to initialize main context objects.
Definition: main_ctx_object.hpp:45
auto color_bits() const noexcept -> valid_if_positive< int >
Returns the number of red, green and blue channel bits.
Definition: options.hpp:220
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
auto offscreen(bool value) noexcept -> auto &
Requests an off-screen rendering surface.
Definition: options.hpp:302
Class holding and managing video-related application options.
Definition: options.hpp:34
auto stencil_bits() const noexcept -> valid_if_positive< int >
Returns the number of stencil buffer bits.
Definition: options.hpp:296
auto enough_frames(span_size_t frame_no) const noexcept -> bool
Says if the application rendered enough frames according to the configuration.
Definition: options.hpp:523
Base class for main context objects.
Definition: main_ctx_object.hpp:71
launch_options(main_ctx_parent parent) noexcept
Constructor with parent main context object.
auto require_input() noexcept -> auto &
Specifies that user input handling is required.
Definition: options.hpp:505
auto video_kind() const noexcept -> video_context_kind
Returns the requested video rendering context kind.
Definition: options.hpp:47
Class for reading application configuration.
Definition: application_config.hpp:29
auto prefer_gles() const noexcept -> bool
Indicates that if both GL and GL|ES is available, ES should be used.
Definition: options.hpp:121
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
auto application_title() const noexcept -> string_view
Returns the title of the application.
auto samples(const valid_samples &value) noexcept -> auto &
Sets the number of per-pixel samples.
Definition: options.hpp:190
Primary template for conditionally valid values.
Definition: decl.hpp:49
auto display_name() const noexcept -> valid_if_not_empty< string_view >
Returns the display name string (this may be provider-specific).
Definition: options.hpp:79
auto depth_bits() const noexcept -> valid_if_positive< int >
Returns the number of depth buffer bits.
Definition: options.hpp:271
auto device_path() const noexcept -> valid_if_not_empty< string_view >
Returns the driver name string (this may be provider-specific).
Definition: options.hpp:95
auto no_input() noexcept -> auto &
Specifies that no user input should be used.
Definition: options.hpp:497
@ opengl
OpenGL© (or OpenGL|ES) context.
auto framedump_stencil() const noexcept -> framedump_data_type
Returns the pixel data type for stencil buffer frame dumps.
Definition: options.hpp:350
auto enough_run_time(std::chrono::duration< R, P > run_time) const noexcept -> bool
Says if the application ran long enough according to the configuration.
Definition: options.hpp:517
auto samples_dont_care() noexcept -> auto &
Sets the number of per-pixel samples to a "don't care" value.
Definition: options.hpp:197
auto with_stencil() noexcept -> auto &
Sets the number of stencil buffer bits to a default non-zero value.
Definition: options.hpp:290
auto doing_framedump() const noexcept -> bool
Indicates if a frame dump render run is requested.
Definition: options.hpp:355
auto required_input() const noexcept -> bool
Indicates if user input handling is required.
Definition: options.hpp:511
auto has_provider(string_view name) const noexcept -> bool
Indicates if video provider name is the same as the argument.
Definition: options.hpp:66
auto offscreen() const noexcept -> bool
Indicates if an off-screen rendering surface was requested.
Definition: options.hpp:311
auto set_provider(std::string name) -> auto &
Sets the video provider identifier name.
Definition: options.hpp:53
audio_context_kind
Audio / sound playback and recodring context kind.
Definition: types.hpp:37
framedump_data_type
Pixel data type used to store frame dump image data.
Definition: types.hpp:72
Class wrapping values that can be loaded from application_config.
Definition: application_config.hpp:197
auto with_alpha() noexcept -> auto &
Sets the number of alpha channel bits to a default non-zero value.
Definition: options.hpp:240
auto framedump_color() const noexcept -> framedump_data_type
Returns the pixel data type for color/alpha buffer frame dumps.
Definition: options.hpp:340
auto with_depth() noexcept -> auto &
Sets the number of depth buffer bits to a default non-zero value.
Definition: options.hpp:265
auto require_video(video_context_kind kind=video_context_kind::opengl, identifier instance={}) -> video_options &
Requests a new video rendering context and surface.
auto surface_size(valid_surface_size width, valid_surface_size height) -> auto &
Sets the rendering surface size.
Definition: options.hpp:166
auto surface_height() const noexcept -> valid_surface_size
Returns the rendering surface height (in pixels).
Definition: options.hpp:181
auto alpha_bits() const noexcept -> valid_if_positive< int >
Returns the number of alpha channel bits.
Definition: options.hpp:246
auto framedump_depth() const noexcept -> framedump_data_type
Returns the pixel data type for depth buffer frame dumps.
Definition: options.hpp:345
auto video_requirements() const noexcept -> const std::map< identifier, video_options > &
Returns all current video rendering context options.
Definition: options.hpp:461
auto gl_compatibility_context() const noexcept -> bool
Returns the preferred GL minor version number.
Definition: options.hpp:146
video_device_kind
Video rendering device kind.
Definition: types.hpp:51
auto no_video() noexcept -> auto &
Specifies that no video rendering should be used.
Definition: options.hpp:443
auto framedump_prefix() const noexcept -> string_view
Returns a filesystem prefix for framedump image files.
Definition: options.hpp:335
video_context_kind
Video / graphics rendering context kind.
Definition: types.hpp:20
auto samples() const noexcept -> valid_if_positive< int >
Returns the number of per-pixel samples.
Definition: options.hpp:203
auto audio_requirements() const noexcept -> const std::map< identifier, audio_options > &
Returns all current audio rendering context options.
Definition: options.hpp:488
@ none
None, not doing frame dump render run.
Class holding and managing audio-related application options.
Definition: options.hpp:405
auto gl_version_major() const noexcept -> valid_gl_major_version
Returns the preferred GL major version number.
Definition: options.hpp:132
auto gl_debug_context() const noexcept -> bool
Indicates if a debug GL context should be created.
Definition: options.hpp:152
auto no_audio() noexcept -> auto &
Specifies that no audio playback or recording should be used.
Definition: options.hpp:470
auto alpha_bits(const valid_alpha_bits &value) noexcept -> auto &
Sets the number of alpha channel bits.
Definition: options.hpp:231
Class managing options for an application with video / audio rendering.
Definition: options.hpp:431
auto stencil_bits(const valid_stencil_bits &value) noexcept -> auto &
Sets the number of stencil buffer bits.
Definition: options.hpp:282
auto color_bits(const valid_color_bits &value) noexcept -> auto &
Sets the number of red, green and blue channel bits.
Definition: options.hpp:214
auto driver_name() const noexcept -> valid_if_not_empty< string_view >
Returns the driver name string (this may be provider-specific).
Definition: options.hpp:87
auto gl_robust_access() const noexcept -> bool
Indicates if a GL context with robust access checks should be created.
Definition: options.hpp:158
Class holding shared video/audio rendering application support objects.
Definition: context.hpp:166
auto fullscreen() const noexcept -> bool
Indicates if an full-screen rendering surface was requested.
Definition: options.hpp:330
auto require_audio(audio_context_kind kind=audio_context_kind::openal, identifier instance={}) -> audio_options &
Requests a new audio playback and recording context.
auto gl_version_minor() const noexcept -> valid_gl_minor_version
Returns the preferred GL major version number.
Definition: options.hpp:139
auto audio_kind() const noexcept
Returns the requested audio rendering context kind.
Definition: options.hpp:413
auto has_provider() const noexcept -> bool
Indicates if video provider name is set (not empty).
Definition: options.hpp:60
auto depth_bits(const valid_depth_bits &value) noexcept -> auto &
Sets the number of depth buffer bits.
Definition: options.hpp:257
auto device_kind() const noexcept -> valid_if_not< video_device_kind, video_device_kind::dont_care >
Returns the rendering device kind (this may be provider-specific).
Definition: options.hpp:104
auto surface_width() const noexcept -> valid_surface_size
Returns the rendering surface width (in pixels).
Definition: options.hpp:175
auto device_index() const noexcept -> valid_if_nonnegative< span_size_t >
Returns the rendering device index (this may be provider-specific).
Definition: options.hpp:114
auto fullscreen(bool value) noexcept -> auto &
Requests an full-screen rendering surface.
Definition: options.hpp:321
auto provider() const noexcept -> valid_if_not_empty< string_view >
Returns the assigned provider name.
Definition: options.hpp:71