diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-24 11:03:25 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-24 11:03:25 +0200 |
commit | c8547d38a29bb4756e3351bdfa45ea72635286d8 (patch) | |
tree | 5cdf9ad44db6f7673734febdccf89b43409a9b9c /main | |
parent | f47790b1ec38f27c486ad2002dac8b310933f0a4 (diff) |
a
Diffstat (limited to 'main')
-rw-r--r-- | main/debug.cpp | 19 | ||||
-rw-r--r-- | main/floormat-app.hpp | 7 | ||||
-rw-r--r-- | main/floormat-main-impl.cpp | 10 | ||||
-rw-r--r-- | main/floormat-main-impl.hpp | 7 | ||||
-rw-r--r-- | main/floormat-main.hpp | 1 |
5 files changed, 29 insertions, 15 deletions
diff --git a/main/debug.cpp b/main/debug.cpp index efc47a6c..14cdad00 100644 --- a/main/debug.cpp +++ b/main/debug.cpp @@ -58,16 +58,29 @@ void main_impl::_debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Ty static_cast<const main_impl*>(self)->debug_callback(src, type, id, severity, str); } -void* main_impl::register_debug_callback() noexcept +void main_impl::register_debug_callback() { GL::DebugOutput::setCallback(_debug_callback, this); -#if 1 +#if 0 /* Disable rather spammy "Buffer detailed info" debug messages on NVidia drivers */ GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false); #endif +} - return nullptr; +char main_impl::maybe_register_debug_callback(fm_gpu_debug flag) +{ + using enum fm_gpu_debug; + switch (flag) + { + default: + register_debug_callback(); + break; + case off: + case no_error: + break; + } + return '\0'; } } // namespace floormat diff --git a/main/floormat-app.hpp b/main/floormat-app.hpp index 6474b66a..3f382e32 100644 --- a/main/floormat-app.hpp +++ b/main/floormat-app.hpp @@ -1,5 +1,4 @@ #pragma once -#include "compat/defs.hpp" namespace Magnum::Math { template<typename T> class Vector2; } @@ -21,8 +20,10 @@ struct floormat_app explicit floormat_app() noexcept; virtual ~floormat_app() noexcept; - fm_DECLARE_DELETED_COPY_ASSIGNMENT(floormat_app); - fm_DECLARE_DEPRECATED_MOVE_ASSIGNMENT(floormat_app); + floormat_app(const floormat_app&) = delete; + floormat_app& operator=(const floormat_app&) = delete; + [[deprecated]] floormat_app(floormat_app&&) = default; + [[deprecated]] floormat_app& operator=(floormat_app&&) = default; virtual void update(float dt) = 0; virtual void maybe_init_chunk(const chunk_coords& pos, chunk& c) = 0; diff --git a/main/floormat-main-impl.cpp b/main/floormat-main-impl.cpp index 92f1c7ce..219b131d 100644 --- a/main/floormat-main-impl.cpp +++ b/main/floormat-main-impl.cpp @@ -16,8 +16,6 @@ floormat_main::floormat_main() noexcept = default; floormat_main::~floormat_main() noexcept = default; main_impl::~main_impl() noexcept = default; -static const char* const fm_fake_argv[] = { "floormat", nullptr }; - auto main_impl::make_window_flags(const fm_settings& s) -> Configuration::WindowFlags { using flag = Configuration::WindowFlag; @@ -82,11 +80,12 @@ void main_impl::recalc_viewport(Vector2i size) noexcept app.on_viewport_event(size); } -// NOLINTNEXTLINE(performance-unnecessary-value-param) +static int fake_argc = 0; + main_impl::main_impl(floormat_app& app, fm_settings&& s) noexcept : - Platform::Sdl2Application{Arguments{fake_argc, fm_fake_argv}, + Platform::Sdl2Application{Arguments{fake_argc, nullptr}, make_conf(s), make_gl_conf(s)}, - app{app}, s{std::move(s)} + s{std::move(s)}, app{app} { switch (s.vsync) // NOLINT(bugprone-use-after-move) { @@ -95,6 +94,7 @@ main_impl::main_impl(floormat_app& app, fm_settings&& s) noexcept : if (const auto list = GL::Context::current().extensionStrings(); std::find(list.cbegin(), list.cend(), "EXT_swap_control_tear") != list.cbegin()) (void)setSwapInterval(-1); + setMinimalLoopPeriod(4); break; case fm_tristate::off: setSwapInterval(0); diff --git a/main/floormat-main-impl.hpp b/main/floormat-main-impl.hpp index 9bcdc6de..4c3a9076 100644 --- a/main/floormat-main-impl.hpp +++ b/main/floormat-main-impl.hpp @@ -26,7 +26,6 @@ struct main_impl final : Platform::Sdl2Application, floormat_main Magnum::Math::Vector2<int> window_size() const noexcept override; tile_shader& shader() noexcept override; const tile_shader& shader() const noexcept override; - void* register_debug_callback() noexcept override; struct world& world() noexcept override; SDL_Window* window() noexcept override; @@ -54,14 +53,14 @@ struct main_impl final : Platform::Sdl2Application, floormat_main void stop_text_input() noexcept override; private: + fm_settings s; + char _dummy = maybe_register_debug_callback(s.gpu_debug); floormat_app& app; tile_shader _shader; struct world _world{}; floor_mesh _floor_mesh; wall_mesh _wall_mesh; Magnum::Timeline timeline; - fm_settings s; - int fake_argc = 1; struct draw_bounds final { std::int16_t minx, maxx, miny, maxy; }; @@ -79,6 +78,8 @@ private: GL::DebugOutput::Severity severity, const std::string& str) const; static void _debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Type type, UnsignedInt id, GL::DebugOutput::Severity severity, const std::string& str, const void* self); + char maybe_register_debug_callback(fm_gpu_debug flag); + void register_debug_callback(); static Configuration make_conf(const fm_settings& s); static GLConfiguration make_gl_conf(const fm_settings& s); diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp index 69b2bf34..f1e5ce8a 100644 --- a/main/floormat-main.hpp +++ b/main/floormat-main.hpp @@ -26,7 +26,6 @@ struct floormat_main virtual Magnum::Math::Vector2<int> window_size() const noexcept = 0; virtual tile_shader& shader() noexcept = 0; virtual const tile_shader& shader() const noexcept = 0; - virtual void* register_debug_callback() noexcept = 0; constexpr float smoothed_dt() const noexcept { return _frame_time; } virtual fm_settings& settings() noexcept = 0; virtual const fm_settings& settings() const noexcept = 0; |