From a00ac8b5fed9d03cb2b3eafb4cd7d04546e341b1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 25 Oct 2022 16:19:21 +0200 Subject: move some headers around --- editor/app.cpp | 4 +- editor/app.hpp | 2 +- editor/camera.cpp | 2 +- editor/draw.cpp | 2 +- editor/events.cpp | 4 +- editor/imgui.cpp | 2 +- editor/update.cpp | 4 +- floormat/app.hpp | 49 +++++++++ floormat/events.hpp | 56 ++++++++++ floormat/main.hpp | 48 +++++++++ floormat/settings.hpp | 35 +++++++ main/app.cpp | 10 ++ main/debug.cpp | 2 +- main/events.cpp | 97 +++++++++++++++++ main/floormat-app.cpp | 10 -- main/floormat-app.hpp | 49 --------- main/floormat-events.cpp | 97 ----------------- main/floormat-events.hpp | 56 ---------- main/floormat-main-impl.cpp | 250 -------------------------------------------- main/floormat-main-impl.hpp | 89 ---------------- main/floormat-main.hpp | 48 --------- main/floormat.hpp | 36 ------- main/main-impl.cpp | 249 +++++++++++++++++++++++++++++++++++++++++++ main/main-impl.hpp | 89 ++++++++++++++++ 24 files changed, 644 insertions(+), 646 deletions(-) create mode 100644 floormat/app.hpp create mode 100644 floormat/events.hpp create mode 100644 floormat/main.hpp create mode 100644 floormat/settings.hpp create mode 100644 main/app.cpp create mode 100644 main/events.cpp delete mode 100644 main/floormat-app.cpp delete mode 100644 main/floormat-app.hpp delete mode 100644 main/floormat-events.cpp delete mode 100644 main/floormat-events.hpp delete mode 100644 main/floormat-main-impl.cpp delete mode 100644 main/floormat-main-impl.hpp delete mode 100644 main/floormat-main.hpp delete mode 100644 main/floormat.hpp create mode 100644 main/main-impl.cpp create mode 100644 main/main-impl.hpp diff --git a/editor/app.cpp b/editor/app.cpp index f89aa002..e28f1a72 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -1,7 +1,7 @@ #include "app.hpp" #include "compat/assert.hpp" -#include "main/floormat-main.hpp" -#include "main/floormat.hpp" +#include "floormat/main.hpp" +#include "floormat/settings.hpp" #include "src/loader.hpp" #include "world.hpp" #include diff --git a/editor/app.hpp b/editor/app.hpp index 663b4923..1cf118f9 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -6,7 +6,7 @@ #include "draw/wireframe-mesh.hpp" #include "draw/wireframe-quad.hpp" #include "draw/wireframe-box.hpp" -#include "main/floormat-app.hpp" +#include "floormat/app.hpp" #include #include diff --git a/editor/camera.cpp b/editor/camera.cpp index 529f55e9..300f0c61 100644 --- a/editor/camera.cpp +++ b/editor/camera.cpp @@ -1,7 +1,7 @@ #include "app.hpp" #include "src/global-coords.hpp" #include "shaders/tile-shader.hpp" -#include "main/floormat-main.hpp" +#include "floormat/main.hpp" #include namespace floormat { diff --git a/editor/draw.cpp b/editor/draw.cpp index 4150bc27..2b047c6b 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -1,5 +1,5 @@ #include "app.hpp" -#include "main/floormat-main.hpp" +#include "floormat/main.hpp" #include "shaders/tile-shader.hpp" #include diff --git a/editor/events.cpp b/editor/events.cpp index cfa0b904..cd846a96 100644 --- a/editor/events.cpp +++ b/editor/events.cpp @@ -1,7 +1,7 @@ #include "app.hpp" -#include "main/floormat-main.hpp" -#include "main/floormat-events.hpp" +#include "floormat/main.hpp" +#include "floormat/events.hpp" #include "src/world.hpp" #include diff --git a/editor/imgui.cpp b/editor/imgui.cpp index b627d34f..7a34f5fc 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -1,5 +1,5 @@ #include "app.hpp" -#include "main/floormat-main.hpp" +#include "floormat/main.hpp" #include #include "imgui-raii.hpp" diff --git a/editor/update.cpp b/editor/update.cpp index 734ed7b5..c0595c45 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -1,7 +1,7 @@ #include "app.hpp" #include "src/chunk.hpp" -#include "main/floormat-events.hpp" -#include "main/floormat-main.hpp" +#include "floormat/events.hpp" +#include "floormat/main.hpp" namespace floormat { diff --git a/floormat/app.hpp b/floormat/app.hpp new file mode 100644 index 00000000..60ecc52c --- /dev/null +++ b/floormat/app.hpp @@ -0,0 +1,49 @@ +#pragma once + +namespace Magnum::Math { template class Vector2; } + +namespace floormat { + +struct mouse_move_event; +struct mouse_button_event; +struct mouse_scroll_event; +struct key_event; +struct text_input_event; +struct text_editing_event; +struct any_event; + +struct chunk_coords; +struct chunk; + +struct floormat_app +{ + explicit floormat_app() noexcept; + virtual ~floormat_app() noexcept; + + 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_initialize_chunk(const chunk_coords& pos, chunk& c) = 0; + virtual void draw_msaa(); + virtual void draw() = 0; + + virtual void on_mouse_move(const mouse_move_event& event) noexcept = 0; + virtual void on_mouse_up_down(const mouse_button_event& event, bool is_down) noexcept = 0; + virtual void on_mouse_scroll(const mouse_scroll_event& event) noexcept = 0; + virtual void on_key_up_down(const key_event& event, bool is_down) noexcept = 0; + virtual void on_text_input_event(const text_input_event& event) noexcept = 0; + //virtual bool on_text_editing_event(const text_editing_event& event) noexcept = 0; + virtual void on_viewport_event(const Magnum::Math::Vector2& size) noexcept = 0; + virtual void on_any_event(const any_event& event) noexcept = 0; + virtual void on_focus_in() noexcept = 0; + virtual void on_focus_out() noexcept = 0; + virtual void on_mouse_leave() noexcept = 0; + virtual void on_mouse_enter() noexcept = 0; +}; + +inline void floormat_app::draw_msaa() {} + +} // namespace floormat diff --git a/floormat/events.hpp b/floormat/events.hpp new file mode 100644 index 00000000..97c5f171 --- /dev/null +++ b/floormat/events.hpp @@ -0,0 +1,56 @@ +#pragma once +#include +#include +#include +#include + +namespace floormat { + +enum mouse_button : std::uint8_t { + mouse_button_none = 0, + mouse_button_left = SDL_BUTTON_LMASK, + mouse_button_middle = SDL_BUTTON_MMASK, + mouse_button_right = SDL_BUTTON_RMASK, + mouse_button_x1 = SDL_BUTTON_X1MASK, + mouse_button_x2 = SDL_BUTTON_X2MASK, +}; + +struct mouse_button_event final { + Vector2i position; + SDL_Keymod mods = KMOD_NONE; + mouse_button button = mouse_button_none; + std::uint8_t click_count = 0; +}; + +struct mouse_move_event final { + Vector2i position, relative_position; + mouse_button buttons = mouse_button_none; + SDL_Keymod mods = KMOD_NONE; +}; + +struct mouse_scroll_event final { + Magnum::Vector2 offset; + Vector2i position; + SDL_Keymod mods = KMOD_NONE; +}; + +struct text_input_event final { + Containers::StringView text; +}; + +struct text_editing_event final { + Containers::StringView text; + std::int32_t start = 0, length = 0; +}; + +struct key_event final { + SDL_Keycode key = SDLK_UNKNOWN; + SDL_Keymod mods = KMOD_NONE; + std::uint8_t is_repeated = false; +}; + +struct any_event final { + SDL_Event event = {}; +}; + +} // namespace floormat diff --git a/floormat/main.hpp b/floormat/main.hpp new file mode 100644 index 00000000..6ba3b4c8 --- /dev/null +++ b/floormat/main.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include "src/global-coords.hpp" +#include + +struct SDL_Window; + +namespace floormat { + +struct fm_settings; +struct floormat_app; +struct tile_shader; +struct world; + +struct floormat_main +{ + floormat_main() noexcept; + virtual ~floormat_main() noexcept; + + fm_DECLARE_DELETED_COPY_ASSIGNMENT(floormat_main); + fm_DECLARE_DEPRECATED_MOVE_ASSIGNMENT(floormat_main); + + virtual int exec() = 0; + virtual void quit(int status) = 0; + + virtual Magnum::Math::Vector2 window_size() const noexcept = 0; + virtual tile_shader& shader() noexcept = 0; + virtual const tile_shader& shader() const 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; + + virtual bool is_text_input_active() const noexcept = 0; + virtual void start_text_input() noexcept = 0; + virtual void stop_text_input() noexcept = 0; + + virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0; + + virtual world& world() noexcept = 0; + virtual SDL_Window* window() noexcept = 0; + + [[nodiscard]] static floormat_main* create(floormat_app& app, fm_settings&& options); + +protected: + float _frame_time = 0; +}; + +} // namespace floormat diff --git a/floormat/settings.hpp b/floormat/settings.hpp new file mode 100644 index 00000000..0a526478 --- /dev/null +++ b/floormat/settings.hpp @@ -0,0 +1,35 @@ +#pragma once +#include "compat/defs.hpp" +#include +#include +#include + +namespace floormat { + +enum class fm_gpu_debug : char { no_error = 1, off, on, robust, }; +enum class fm_tristate : char { maybe = -1, on, off }; +enum class fm_log_level : unsigned char { quiet, normal, verbose, }; + +struct fm_settings +{ + inline fm_settings() noexcept = default; + virtual ~fm_settings() noexcept; + fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(fm_settings); + fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(fm_settings); + + Magnum::Math::Vector2 resolution{1024, 768}; + Corrade::Containers::String title{"Test"}; + Corrade::Containers::String disabled_extensions; // TODO + std::uint8_t msaa_samples = 16; + fm_tristate vsync = fm_tristate::maybe; + fm_gpu_debug gpu_debug = fm_gpu_debug::on; + fm_log_level log_level = fm_log_level::normal; + std::uint8_t resizable : 1 = true, + fullscreen : 1 = false, + fullscreen_desktop : 1 = false, + borderless : 1 = false, + maximized : 1 = false, + msaa : 1 = true; +}; + +} // namespace floormat diff --git a/main/app.cpp b/main/app.cpp new file mode 100644 index 00000000..91b4ccaf --- /dev/null +++ b/main/app.cpp @@ -0,0 +1,10 @@ +#include "floormat/app.hpp" +#include "floormat/settings.hpp" + +namespace floormat { + +floormat_app::floormat_app() noexcept = default; +floormat_app::~floormat_app() noexcept = default; +fm_settings::~fm_settings() noexcept = default; + +} // namespace floormat diff --git a/main/debug.cpp b/main/debug.cpp index f46c63d5..a8483cd0 100644 --- a/main/debug.cpp +++ b/main/debug.cpp @@ -1,4 +1,4 @@ -#include "floormat-main-impl.hpp" +#include "main-impl.hpp" #include namespace floormat { diff --git a/main/events.cpp b/main/events.cpp new file mode 100644 index 00000000..ac8f0766 --- /dev/null +++ b/main/events.cpp @@ -0,0 +1,97 @@ +#include "main-impl.hpp" +#include "floormat/app.hpp" +#include "floormat/events.hpp" +#include "compat/assert.hpp" +#include +#include + +namespace floormat { + +void main_impl::viewportEvent(Platform::Sdl2Application::ViewportEvent& event) +{ + fm_assert(event.framebufferSize() == event.windowSize()); + recalc_viewport(event.windowSize()); + app.on_viewport_event(event.windowSize()); +} + +void main_impl::mousePressEvent(Platform::Sdl2Application::MouseEvent& event) +{ + app.on_mouse_up_down({event.position(), + (SDL_Keymod)(std::uint16_t)event.modifiers(), + mouse_button(SDL_BUTTON((std::uint8_t)event.button())), + std::uint8_t(std::min(255, event.clickCount()))}, + true); +} + +void main_impl::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event) +{ + app.on_mouse_up_down({event.position(), + (SDL_Keymod)(std::uint16_t)event.modifiers(), + mouse_button(SDL_BUTTON((std::uint8_t)event.button())), + std::uint8_t(std::min(255, event.clickCount()))}, + false); +} + +void main_impl::mouseMoveEvent(Platform::Sdl2Application::MouseMoveEvent& event) +{ + app.on_mouse_move({event.position(), event.relativePosition(), + (mouse_button)(std::uint8_t)(std::uint32_t)event.buttons(), + (SDL_Keymod)(std::uint16_t)event.modifiers()}); +} + +void main_impl::mouseScrollEvent(Platform::Sdl2Application::MouseScrollEvent& event) +{ + app.on_mouse_scroll({event.offset(), event.position(), + (SDL_Keymod)(std::uint16_t)event.modifiers()}); +} + +void main_impl::textInputEvent(Platform::Sdl2Application::TextInputEvent& event) +{ + app.on_text_input_event({event.text()}); +} + +#if 0 +void main_impl::textEditingEvent(Platform::Sdl2Application::TextEditingEvent& event) +{ + app.on_text_editing_event({event.text(), event.start(), event.length()}) +} +#endif + +void main_impl::keyPressEvent(Platform::Sdl2Application::KeyEvent& event) +{ + app.on_key_up_down({(SDL_Keycode)(std::uint32_t)event.key(), + (SDL_Keymod)(std::uint16_t)event.modifiers(), + event.isRepeated()}, + true); +} + +void main_impl::keyReleaseEvent(Platform::Sdl2Application::KeyEvent& event) +{ + app.on_key_up_down({(SDL_Keycode)(std::uint32_t)event.key(), + (SDL_Keymod)(std::uint16_t)event.modifiers(), + event.isRepeated()}, + false); +} + +void main_impl::anyEvent(SDL_Event& event) +{ + if (event.type == SDL_WINDOWEVENT) + switch (event.window.event) + { + case SDL_WINDOWEVENT_FOCUS_LOST: + return app.on_focus_out(); + case SDL_WINDOWEVENT_FOCUS_GAINED: + return app.on_focus_in(); + case SDL_WINDOWEVENT_LEAVE: + return app.on_mouse_leave(); + case SDL_WINDOWEVENT_ENTER: + return app.on_mouse_enter(); + default: + return app.on_any_event({event}); + } + else + return app.on_any_event({event}); +} + +} // namespace floormat + diff --git a/main/floormat-app.cpp b/main/floormat-app.cpp deleted file mode 100644 index 2f69c0da..00000000 --- a/main/floormat-app.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "floormat-app.hpp" -#include "floormat.hpp" - -namespace floormat { - -floormat_app::floormat_app() noexcept = default; -floormat_app::~floormat_app() noexcept = default; -fm_settings::~fm_settings() noexcept = default; - -} // namespace floormat diff --git a/main/floormat-app.hpp b/main/floormat-app.hpp deleted file mode 100644 index 60ecc52c..00000000 --- a/main/floormat-app.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -namespace Magnum::Math { template class Vector2; } - -namespace floormat { - -struct mouse_move_event; -struct mouse_button_event; -struct mouse_scroll_event; -struct key_event; -struct text_input_event; -struct text_editing_event; -struct any_event; - -struct chunk_coords; -struct chunk; - -struct floormat_app -{ - explicit floormat_app() noexcept; - virtual ~floormat_app() noexcept; - - 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_initialize_chunk(const chunk_coords& pos, chunk& c) = 0; - virtual void draw_msaa(); - virtual void draw() = 0; - - virtual void on_mouse_move(const mouse_move_event& event) noexcept = 0; - virtual void on_mouse_up_down(const mouse_button_event& event, bool is_down) noexcept = 0; - virtual void on_mouse_scroll(const mouse_scroll_event& event) noexcept = 0; - virtual void on_key_up_down(const key_event& event, bool is_down) noexcept = 0; - virtual void on_text_input_event(const text_input_event& event) noexcept = 0; - //virtual bool on_text_editing_event(const text_editing_event& event) noexcept = 0; - virtual void on_viewport_event(const Magnum::Math::Vector2& size) noexcept = 0; - virtual void on_any_event(const any_event& event) noexcept = 0; - virtual void on_focus_in() noexcept = 0; - virtual void on_focus_out() noexcept = 0; - virtual void on_mouse_leave() noexcept = 0; - virtual void on_mouse_enter() noexcept = 0; -}; - -inline void floormat_app::draw_msaa() {} - -} // namespace floormat diff --git a/main/floormat-events.cpp b/main/floormat-events.cpp deleted file mode 100644 index 0ef380fb..00000000 --- a/main/floormat-events.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "floormat-main-impl.hpp" -#include "floormat-app.hpp" -#include "floormat-events.hpp" -#include "compat/assert.hpp" -#include -#include - -namespace floormat { - -void main_impl::viewportEvent(Platform::Sdl2Application::ViewportEvent& event) -{ - fm_assert(event.framebufferSize() == event.windowSize()); - recalc_viewport(event.windowSize()); - app.on_viewport_event(event.windowSize()); -} - -void main_impl::mousePressEvent(Platform::Sdl2Application::MouseEvent& event) -{ - app.on_mouse_up_down({event.position(), - (SDL_Keymod)(std::uint16_t)event.modifiers(), - mouse_button(SDL_BUTTON((std::uint8_t)event.button())), - std::uint8_t(std::min(255, event.clickCount()))}, - true); -} - -void main_impl::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event) -{ - app.on_mouse_up_down({event.position(), - (SDL_Keymod)(std::uint16_t)event.modifiers(), - mouse_button(SDL_BUTTON((std::uint8_t)event.button())), - std::uint8_t(std::min(255, event.clickCount()))}, - false); -} - -void main_impl::mouseMoveEvent(Platform::Sdl2Application::MouseMoveEvent& event) -{ - app.on_mouse_move({event.position(), event.relativePosition(), - (mouse_button)(std::uint8_t)(std::uint32_t)event.buttons(), - (SDL_Keymod)(std::uint16_t)event.modifiers()}); -} - -void main_impl::mouseScrollEvent(Platform::Sdl2Application::MouseScrollEvent& event) -{ - app.on_mouse_scroll({event.offset(), event.position(), - (SDL_Keymod)(std::uint16_t)event.modifiers()}); -} - -void main_impl::textInputEvent(Platform::Sdl2Application::TextInputEvent& event) -{ - app.on_text_input_event({event.text()}); -} - -#if 0 -void main_impl::textEditingEvent(Platform::Sdl2Application::TextEditingEvent& event) -{ - app.on_text_editing_event({event.text(), event.start(), event.length()}) -} -#endif - -void main_impl::keyPressEvent(Platform::Sdl2Application::KeyEvent& event) -{ - app.on_key_up_down({(SDL_Keycode)(std::uint32_t)event.key(), - (SDL_Keymod)(std::uint16_t)event.modifiers(), - event.isRepeated()}, - true); -} - -void main_impl::keyReleaseEvent(Platform::Sdl2Application::KeyEvent& event) -{ - app.on_key_up_down({(SDL_Keycode)(std::uint32_t)event.key(), - (SDL_Keymod)(std::uint16_t)event.modifiers(), - event.isRepeated()}, - false); -} - -void main_impl::anyEvent(SDL_Event& event) -{ - if (event.type == SDL_WINDOWEVENT) - switch (event.window.event) - { - case SDL_WINDOWEVENT_FOCUS_LOST: - return app.on_focus_out(); - case SDL_WINDOWEVENT_FOCUS_GAINED: - return app.on_focus_in(); - case SDL_WINDOWEVENT_LEAVE: - return app.on_mouse_leave(); - case SDL_WINDOWEVENT_ENTER: - return app.on_mouse_enter(); - default: - return app.on_any_event({event}); - } - else - return app.on_any_event({event}); -} - -} // namespace floormat - diff --git a/main/floormat-events.hpp b/main/floormat-events.hpp deleted file mode 100644 index 97c5f171..00000000 --- a/main/floormat-events.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace floormat { - -enum mouse_button : std::uint8_t { - mouse_button_none = 0, - mouse_button_left = SDL_BUTTON_LMASK, - mouse_button_middle = SDL_BUTTON_MMASK, - mouse_button_right = SDL_BUTTON_RMASK, - mouse_button_x1 = SDL_BUTTON_X1MASK, - mouse_button_x2 = SDL_BUTTON_X2MASK, -}; - -struct mouse_button_event final { - Vector2i position; - SDL_Keymod mods = KMOD_NONE; - mouse_button button = mouse_button_none; - std::uint8_t click_count = 0; -}; - -struct mouse_move_event final { - Vector2i position, relative_position; - mouse_button buttons = mouse_button_none; - SDL_Keymod mods = KMOD_NONE; -}; - -struct mouse_scroll_event final { - Magnum::Vector2 offset; - Vector2i position; - SDL_Keymod mods = KMOD_NONE; -}; - -struct text_input_event final { - Containers::StringView text; -}; - -struct text_editing_event final { - Containers::StringView text; - std::int32_t start = 0, length = 0; -}; - -struct key_event final { - SDL_Keycode key = SDLK_UNKNOWN; - SDL_Keymod mods = KMOD_NONE; - std::uint8_t is_repeated = false; -}; - -struct any_event final { - SDL_Event event = {}; -}; - -} // namespace floormat diff --git a/main/floormat-main-impl.cpp b/main/floormat-main-impl.cpp deleted file mode 100644 index 1f35024e..00000000 --- a/main/floormat-main-impl.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include "floormat-main-impl.hpp" -#include "floormat.hpp" -#include "floormat-app.hpp" -#include "compat/assert.hpp" -#include "compat/fpu.hpp" -#include "src/chunk.hpp" -#include "src/world.hpp" -#include "src/camera-offset.hpp" -#include -#include - -//#define FM_SKIP_MSAA - -namespace floormat { - -floormat_main::floormat_main() noexcept = default; -floormat_main::~floormat_main() noexcept = default; -main_impl::~main_impl() noexcept = default; - -auto main_impl::make_window_flags(const fm_settings& s) -> Configuration::WindowFlags -{ - using flag = Configuration::WindowFlag; - Configuration::WindowFlags flags{}; - if (s.resizable) - flags |= flag::Resizable; - if (s.fullscreen) - flags |= flag::Fullscreen; - if (s.fullscreen_desktop) - flags |= flag::FullscreenDesktop; - if (s.borderless) - flags |= flag::Borderless; - if (s.maximized) - flags |= flag::Maximized; - return flags; -} - -auto main_impl::make_conf(const fm_settings& s) -> Configuration -{ - switch (s.log_level) - { - default: - SDL_setenv("MAGNUM_LOG_LEVEL", "normal", 1); - break; - case fm_log_level::quiet: - SDL_setenv("MAGNUM_LOG_LEVEL", "quiet", 1); - break; - case fm_log_level::verbose: - SDL_setenv("MAGNUM_LOG_LEVEL", "verbose", 1); - break; - } - return Configuration{} - .setTitle(s.title) - .setSize(s.resolution) - .setWindowFlags(make_window_flags(s)); -} - -auto main_impl::make_gl_conf(const fm_settings& s) -> GLConfiguration -{ - GLConfiguration::Flags flags{}; - using f = GLConfiguration::Flag; - if (s.gpu_debug >= fm_gpu_debug::on) - flags |= f::Debug | f::GpuValidation; - if (s.gpu_debug >= fm_gpu_debug::robust) - flags |= f::RobustAccess; - else if (s.gpu_debug <= fm_gpu_debug::no_error) - flags |= f::NoError; - return GLConfiguration{}.setFlags(flags); -} - -void main_impl::recalc_viewport(Vector2i size) noexcept -{ - GL::defaultFramebuffer.setViewport({{}, size }); - _msaa_framebuffer.detach(GL::Framebuffer::ColorAttachment{0}); - _msaa_renderbuffer = Magnum::GL::Renderbuffer{}; - _msaa_renderbuffer.setStorageMultisample(s.msaa_samples, GL::RenderbufferFormat::RGBA8, size); - _msaa_framebuffer.setViewport({{}, size }); - _msaa_framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _msaa_renderbuffer); - _shader.set_scale(Vector2{size}); - app.on_viewport_event(size); -} - -main_impl::main_impl(floormat_app& app, fm_settings&& s, int& fake_argc) noexcept : - Platform::Sdl2Application{Arguments{fake_argc, nullptr}, - make_conf(s), make_gl_conf(s)}, - s{std::move(s)}, app{app} -{ - switch (s.vsync) // NOLINT(bugprone-use-after-move) - { - case fm_tristate::on: - (void)setSwapInterval(1); - if (const auto list = GL::Context::current().extensionStrings(); - std::find(list.cbegin(), list.cend(), "EXT_swap_control_tear") != list.cbegin()) - (void)setSwapInterval(-1); - setMinimalLoopPeriod(0); - break; - case fm_tristate::off: - setSwapInterval(0); - break; - default: break; - } - set_fp_mask(); - fm_assert(framebufferSize() == windowSize()); - timeline.start(); -} - -global_coords main_impl::pixel_to_tile(Vector2d position) const noexcept -{ - constexpr Vector2d pixel_size{dTILE_SIZE[0], dTILE_SIZE[1]}; - constexpr Vector2d half{.5, .5}; - const Vector2d px = position - Vector2d{windowSize()}*.5 - _shader.camera_offset()*.5; - const Vector2d vec = tile_shader::unproject(px) / pixel_size + half; - const auto x = (std::int32_t)std::floor(vec[0]), y = (std::int32_t)std::floor(vec[1]); - return { x, y }; -} - -auto main_impl::get_draw_bounds() const noexcept -> draw_bounds -{ - - using limits = std::numeric_limits; - auto x0 = limits::max(), x1 = limits::min(), y0 = limits::max(), y1 = limits::min(); - - for (const auto win = Vector2d(windowSize()); - auto p : {pixel_to_tile(Vector2d{0, 0}).chunk(), - pixel_to_tile(Vector2d{win[0]-1, 0}).chunk(), - pixel_to_tile(Vector2d{0, win[1]-1}).chunk(), - pixel_to_tile(Vector2d{win[0]-1, win[1]-1}).chunk()}) - { - x0 = std::min(x0, p.x); - x1 = std::max(x1, p.x); - y0 = std::min(y0, p.y); - y1 = std::max(y1, p.y); - } - return {x0, x1, y0, y1}; -} - -void main_impl::draw_world() noexcept -{ - auto [minx, maxx, miny, maxy] = get_draw_bounds(); - - for (std::int16_t y = miny; y <= maxy; y++) - for (std::int16_t x = minx; x <= maxx; x++) - { - if (const chunk_coords c = {x, y}; !_world.contains(c)) - app.maybe_initialize_chunk(c, _world[c]); - const chunk_coords c{x, y}; - const with_shifted_camera_offset o{_shader, c}; - _floor_mesh.draw(_shader, _world[c]); - } - - for (std::int16_t y = miny; y <= maxy; y++) - for (std::int16_t x = minx; x <= maxx; x++) - { - const chunk_coords c{x, y}; - const with_shifted_camera_offset o{_shader, c}; - _wall_mesh.draw(_shader, _world[c]); - } -} - -void main_impl::drawEvent() -{ - if (const float dt = timeline.previousFrameDuration(); dt > 0) - { - constexpr float RC = 0.1f; - const float alpha = dt/(dt + RC); - - _frame_time = _frame_time*(1-alpha) + alpha*dt; - } - else - { - swapBuffers(); - timeline.nextFrame(); - } - - { - float dt_max; - unsigned min_loop_period; - - if (const auto flags = SDL_GetWindowFlags(window()); - flags & SDL_WINDOW_HIDDEN) - { - dt_max = 1 + 1e-3f; - min_loop_period = 1000; - } - else if (!(flags & (SDL_WINDOW_INPUT_FOCUS|SDL_WINDOW_MOUSE_FOCUS))) - { - dt_max = 1.f/10; - min_loop_period = 1000/12; - } - else - { - dt_max = 1e-1f; - min_loop_period = 0; - } - - const float dt = std::clamp(timeline.previousFrameDuration(), 1e-6f, dt_max); - setMinimalLoopPeriod(min_loop_period); - - app.update(dt); - } - - _shader.set_tint({1, 1, 1, 1}); - - { - GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); -#ifndef FM_SKIP_MSAA - _msaa_framebuffer.clear(GL::FramebufferClear::Color); - _msaa_framebuffer.bind(); -#endif - draw_world(); - app.draw_msaa(); -#ifndef FM_SKIP_MSAA - GL::defaultFramebuffer.bind(); - GL::Framebuffer::blit(_msaa_framebuffer, GL::defaultFramebuffer, {{}, windowSize()}, GL::FramebufferBlit::Color); -#endif - } - - app.draw(); - - swapBuffers(); - redraw(); - timeline.nextFrame(); -} - -void main_impl::quit(int status) { Platform::Sdl2Application::exit(status); } -struct world& main_impl::world() noexcept { return _world; } -SDL_Window* main_impl::window() noexcept { return Sdl2Application::window(); } -fm_settings& main_impl::settings() noexcept { return s; } -const fm_settings& main_impl::settings() const noexcept { return s; } -Vector2i main_impl::window_size() const noexcept { return windowSize(); } -tile_shader& main_impl::shader() noexcept { return _shader; } -const tile_shader& main_impl::shader() const noexcept { return _shader; } -bool main_impl::is_text_input_active() const noexcept { return const_cast(*this).isTextInputActive(); } -void main_impl::start_text_input() noexcept { startTextInput(); } -void main_impl::stop_text_input() noexcept { stopTextInput(); } - -int main_impl::exec() -{ - recalc_viewport(windowSize()); - return Sdl2Application::exec(); -} - -floormat_main* floormat_main::create(floormat_app& app, fm_settings&& options) -{ - int fake_argc = 0; - auto* ret = new main_impl(app, std::move(options), fake_argc); - fm_assert(ret); - return ret; -} - -} // namespace floormat diff --git a/main/floormat-main-impl.hpp b/main/floormat-main-impl.hpp deleted file mode 100644 index e0a7f1e1..00000000 --- a/main/floormat-main-impl.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once -#include "floormat.hpp" -#include "floormat-main.hpp" -#include "src/world.hpp" -#include "draw/floor-mesh.hpp" -#include "draw/wall-mesh.hpp" -#include "shaders/tile-shader.hpp" - -#include - -#include -#include -#include -#include -#include -#include - -namespace floormat { - -struct floormat_app; - -struct main_impl final : Platform::Sdl2Application, floormat_main -{ - explicit main_impl(floormat_app& app, fm_settings&& opts, int& fake_argc) noexcept; - ~main_impl() noexcept override; - - int exec() override; - void quit(int status) override; - - Magnum::Math::Vector2 window_size() const noexcept override; - tile_shader& shader() noexcept override; - const tile_shader& shader() const noexcept override; - - struct world& world() noexcept override; - SDL_Window* window() noexcept override; - - fm_settings& settings() noexcept override; - const fm_settings& settings() const noexcept override; - - global_coords pixel_to_tile(Vector2d position) const noexcept override; - - [[maybe_unused]] void viewportEvent(ViewportEvent& event) override; - [[maybe_unused]] void mousePressEvent(MouseEvent& event) override; - [[maybe_unused]] void mouseReleaseEvent(MouseEvent& event) override; - [[maybe_unused]] void mouseMoveEvent(MouseMoveEvent& event) override; - [[maybe_unused]] void mouseScrollEvent(MouseScrollEvent& event) override; - [[maybe_unused]] void textInputEvent(TextInputEvent& event) override; - //[[maybe_unused]] void textEditingEvent(TextEditingEvent& event) override; - [[maybe_unused]] void keyPressEvent(KeyEvent& event) override; - [[maybe_unused]] void keyReleaseEvent(KeyEvent& event) override; - [[maybe_unused]] void anyEvent(SDL_Event& event) override; - - void drawEvent() override; - - bool is_text_input_active() const noexcept override; - void start_text_input() noexcept override; - void stop_text_input() noexcept override; - - void debug_callback(unsigned src, unsigned type, unsigned id, unsigned severity, const std::string& str) const; - -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; - - struct draw_bounds final { std::int16_t minx, maxx, miny, maxy; }; - - GL::Framebuffer _msaa_framebuffer{{{}, window_size()}}; - GL::Renderbuffer _msaa_renderbuffer{}; - - void recalc_viewport(Vector2i size) noexcept; - void draw_world() noexcept; - - draw_bounds get_draw_bounds() const noexcept; - - 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); - static Configuration::WindowFlags make_window_flags(const fm_settings& s); -}; - -} // namespace floormat diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp deleted file mode 100644 index 6ba3b4c8..00000000 --- a/main/floormat-main.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "src/global-coords.hpp" -#include - -struct SDL_Window; - -namespace floormat { - -struct fm_settings; -struct floormat_app; -struct tile_shader; -struct world; - -struct floormat_main -{ - floormat_main() noexcept; - virtual ~floormat_main() noexcept; - - fm_DECLARE_DELETED_COPY_ASSIGNMENT(floormat_main); - fm_DECLARE_DEPRECATED_MOVE_ASSIGNMENT(floormat_main); - - virtual int exec() = 0; - virtual void quit(int status) = 0; - - virtual Magnum::Math::Vector2 window_size() const noexcept = 0; - virtual tile_shader& shader() noexcept = 0; - virtual const tile_shader& shader() const 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; - - virtual bool is_text_input_active() const noexcept = 0; - virtual void start_text_input() noexcept = 0; - virtual void stop_text_input() noexcept = 0; - - virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0; - - virtual world& world() noexcept = 0; - virtual SDL_Window* window() noexcept = 0; - - [[nodiscard]] static floormat_main* create(floormat_app& app, fm_settings&& options); - -protected: - float _frame_time = 0; -}; - -} // namespace floormat diff --git a/main/floormat.hpp b/main/floormat.hpp deleted file mode 100644 index 3bf4b492..00000000 --- a/main/floormat.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "compat/defs.hpp" -#include -#include -#include - -namespace floormat { - -enum class fm_gpu_debug : char { no_error = 1, off, on, robust, }; -enum class fm_tristate : char { maybe = -1, on, off }; -enum class fm_log_level : unsigned char { quiet, normal, verbose, }; - -struct fm_settings -{ - inline fm_settings() noexcept = default; - virtual ~fm_settings() noexcept; - fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(fm_settings); - fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(fm_settings); - - Magnum::Math::Vector2 resolution{1024, 768}; - Corrade::Containers::String title{"Test"}; - Corrade::Containers::String disabled_extensions; // TODO - std::uint8_t msaa_samples = 16; - fm_tristate vsync = fm_tristate::maybe; - fm_gpu_debug gpu_debug = fm_gpu_debug::on; - fm_log_level log_level = fm_log_level::normal; - std::uint8_t resizable : 1 = true, - fullscreen : 1 = false, - fullscreen_desktop : 1 = false, - borderless : 1 = false, - maximized : 1 = false, - msaa : 1 = true; -}; - -} // namespace floormat - diff --git a/main/main-impl.cpp b/main/main-impl.cpp new file mode 100644 index 00000000..856635d2 --- /dev/null +++ b/main/main-impl.cpp @@ -0,0 +1,249 @@ +#include "main-impl.hpp" +#include "floormat/app.hpp" +#include "compat/assert.hpp" +#include "compat/fpu.hpp" +#include "src/chunk.hpp" +#include "src/world.hpp" +#include "src/camera-offset.hpp" +#include +#include + +//#define FM_SKIP_MSAA + +namespace floormat { + +floormat_main::floormat_main() noexcept = default; +floormat_main::~floormat_main() noexcept = default; +main_impl::~main_impl() noexcept = default; + +auto main_impl::make_window_flags(const fm_settings& s) -> Configuration::WindowFlags +{ + using flag = Configuration::WindowFlag; + Configuration::WindowFlags flags{}; + if (s.resizable) + flags |= flag::Resizable; + if (s.fullscreen) + flags |= flag::Fullscreen; + if (s.fullscreen_desktop) + flags |= flag::FullscreenDesktop; + if (s.borderless) + flags |= flag::Borderless; + if (s.maximized) + flags |= flag::Maximized; + return flags; +} + +auto main_impl::make_conf(const fm_settings& s) -> Configuration +{ + switch (s.log_level) + { + default: + SDL_setenv("MAGNUM_LOG_LEVEL", "normal", 1); + break; + case fm_log_level::quiet: + SDL_setenv("MAGNUM_LOG_LEVEL", "quiet", 1); + break; + case fm_log_level::verbose: + SDL_setenv("MAGNUM_LOG_LEVEL", "verbose", 1); + break; + } + return Configuration{} + .setTitle(s.title) + .setSize(s.resolution) + .setWindowFlags(make_window_flags(s)); +} + +auto main_impl::make_gl_conf(const fm_settings& s) -> GLConfiguration +{ + GLConfiguration::Flags flags{}; + using f = GLConfiguration::Flag; + if (s.gpu_debug >= fm_gpu_debug::on) + flags |= f::Debug | f::GpuValidation; + if (s.gpu_debug >= fm_gpu_debug::robust) + flags |= f::RobustAccess; + else if (s.gpu_debug <= fm_gpu_debug::no_error) + flags |= f::NoError; + return GLConfiguration{}.setFlags(flags); +} + +void main_impl::recalc_viewport(Vector2i size) noexcept +{ + GL::defaultFramebuffer.setViewport({{}, size }); + _msaa_framebuffer.detach(GL::Framebuffer::ColorAttachment{0}); + _msaa_renderbuffer = Magnum::GL::Renderbuffer{}; + _msaa_renderbuffer.setStorageMultisample(s.msaa_samples, GL::RenderbufferFormat::RGBA8, size); + _msaa_framebuffer.setViewport({{}, size }); + _msaa_framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _msaa_renderbuffer); + _shader.set_scale(Vector2{size}); + app.on_viewport_event(size); +} + +main_impl::main_impl(floormat_app& app, fm_settings&& s, int& fake_argc) noexcept : + Platform::Sdl2Application{Arguments{fake_argc, nullptr}, + make_conf(s), make_gl_conf(s)}, + s{std::move(s)}, app{app} +{ + switch (s.vsync) // NOLINT(bugprone-use-after-move) + { + case fm_tristate::on: + (void)setSwapInterval(1); + if (const auto list = GL::Context::current().extensionStrings(); + std::find(list.cbegin(), list.cend(), "EXT_swap_control_tear") != list.cbegin()) + (void)setSwapInterval(-1); + setMinimalLoopPeriod(0); + break; + case fm_tristate::off: + setSwapInterval(0); + break; + default: break; + } + set_fp_mask(); + fm_assert(framebufferSize() == windowSize()); + timeline.start(); +} + +global_coords main_impl::pixel_to_tile(Vector2d position) const noexcept +{ + constexpr Vector2d pixel_size{dTILE_SIZE[0], dTILE_SIZE[1]}; + constexpr Vector2d half{.5, .5}; + const Vector2d px = position - Vector2d{windowSize()}*.5 - _shader.camera_offset()*.5; + const Vector2d vec = tile_shader::unproject(px) / pixel_size + half; + const auto x = (std::int32_t)std::floor(vec[0]), y = (std::int32_t)std::floor(vec[1]); + return { x, y }; +} + +auto main_impl::get_draw_bounds() const noexcept -> draw_bounds +{ + + using limits = std::numeric_limits; + auto x0 = limits::max(), x1 = limits::min(), y0 = limits::max(), y1 = limits::min(); + + for (const auto win = Vector2d(windowSize()); + auto p : {pixel_to_tile(Vector2d{0, 0}).chunk(), + pixel_to_tile(Vector2d{win[0]-1, 0}).chunk(), + pixel_to_tile(Vector2d{0, win[1]-1}).chunk(), + pixel_to_tile(Vector2d{win[0]-1, win[1]-1}).chunk()}) + { + x0 = std::min(x0, p.x); + x1 = std::max(x1, p.x); + y0 = std::min(y0, p.y); + y1 = std::max(y1, p.y); + } + return {x0, x1, y0, y1}; +} + +void main_impl::draw_world() noexcept +{ + auto [minx, maxx, miny, maxy] = get_draw_bounds(); + + for (std::int16_t y = miny; y <= maxy; y++) + for (std::int16_t x = minx; x <= maxx; x++) + { + if (const chunk_coords c = {x, y}; !_world.contains(c)) + app.maybe_initialize_chunk(c, _world[c]); + const chunk_coords c{x, y}; + const with_shifted_camera_offset o{_shader, c}; + _floor_mesh.draw(_shader, _world[c]); + } + + for (std::int16_t y = miny; y <= maxy; y++) + for (std::int16_t x = minx; x <= maxx; x++) + { + const chunk_coords c{x, y}; + const with_shifted_camera_offset o{_shader, c}; + _wall_mesh.draw(_shader, _world[c]); + } +} + +void main_impl::drawEvent() +{ + if (const float dt = timeline.previousFrameDuration(); dt > 0) + { + constexpr float RC = 0.1f; + const float alpha = dt/(dt + RC); + + _frame_time = _frame_time*(1-alpha) + alpha*dt; + } + else + { + swapBuffers(); + timeline.nextFrame(); + } + + { + float dt_max; + unsigned min_loop_period; + + if (const auto flags = SDL_GetWindowFlags(window()); + flags & SDL_WINDOW_HIDDEN) + { + dt_max = 1 + 1e-3f; + min_loop_period = 1000; + } + else if (!(flags & (SDL_WINDOW_INPUT_FOCUS|SDL_WINDOW_MOUSE_FOCUS))) + { + dt_max = 1.f/10; + min_loop_period = 1000/12; + } + else + { + dt_max = 1e-1f; + min_loop_period = 0; + } + + const float dt = std::clamp(timeline.previousFrameDuration(), 1e-6f, dt_max); + setMinimalLoopPeriod(min_loop_period); + + app.update(dt); + } + + _shader.set_tint({1, 1, 1, 1}); + + { + GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); +#ifndef FM_SKIP_MSAA + _msaa_framebuffer.clear(GL::FramebufferClear::Color); + _msaa_framebuffer.bind(); +#endif + draw_world(); + app.draw_msaa(); +#ifndef FM_SKIP_MSAA + GL::defaultFramebuffer.bind(); + GL::Framebuffer::blit(_msaa_framebuffer, GL::defaultFramebuffer, {{}, windowSize()}, GL::FramebufferBlit::Color); +#endif + } + + app.draw(); + + swapBuffers(); + redraw(); + timeline.nextFrame(); +} + +void main_impl::quit(int status) { Platform::Sdl2Application::exit(status); } +struct world& main_impl::world() noexcept { return _world; } +SDL_Window* main_impl::window() noexcept { return Sdl2Application::window(); } +fm_settings& main_impl::settings() noexcept { return s; } +const fm_settings& main_impl::settings() const noexcept { return s; } +Vector2i main_impl::window_size() const noexcept { return windowSize(); } +tile_shader& main_impl::shader() noexcept { return _shader; } +const tile_shader& main_impl::shader() const noexcept { return _shader; } +bool main_impl::is_text_input_active() const noexcept { return const_cast(*this).isTextInputActive(); } +void main_impl::start_text_input() noexcept { startTextInput(); } +void main_impl::stop_text_input() noexcept { stopTextInput(); } + +int main_impl::exec() +{ + recalc_viewport(windowSize()); + return Sdl2Application::exec(); +} + +floormat_main* floormat_main::create(floormat_app& app, fm_settings&& options) +{ + int fake_argc = 0; + auto* ret = new main_impl(app, std::move(options), fake_argc); + fm_assert(ret); + return ret; +} + +} // namespace floormat diff --git a/main/main-impl.hpp b/main/main-impl.hpp new file mode 100644 index 00000000..39a877fe --- /dev/null +++ b/main/main-impl.hpp @@ -0,0 +1,89 @@ +#pragma once +#include "floormat/main.hpp" +#include "floormat/settings.hpp" +#include "src/world.hpp" +#include "draw/floor-mesh.hpp" +#include "draw/wall-mesh.hpp" +#include "shaders/tile-shader.hpp" + +#include + +#include +#include +#include +#include +#include +#include + +namespace floormat { + +struct floormat_app; + +struct main_impl final : Platform::Sdl2Application, floormat_main +{ + explicit main_impl(floormat_app& app, fm_settings&& opts, int& fake_argc) noexcept; + ~main_impl() noexcept override; + + int exec() override; + void quit(int status) override; + + Magnum::Math::Vector2 window_size() const noexcept override; + tile_shader& shader() noexcept override; + const tile_shader& shader() const noexcept override; + + struct world& world() noexcept override; + SDL_Window* window() noexcept override; + + fm_settings& settings() noexcept override; + const fm_settings& settings() const noexcept override; + + global_coords pixel_to_tile(Vector2d position) const noexcept override; + + [[maybe_unused]] void viewportEvent(ViewportEvent& event) override; + [[maybe_unused]] void mousePressEvent(MouseEvent& event) override; + [[maybe_unused]] void mouseReleaseEvent(MouseEvent& event) override; + [[maybe_unused]] void mouseMoveEvent(MouseMoveEvent& event) override; + [[maybe_unused]] void mouseScrollEvent(MouseScrollEvent& event) override; + [[maybe_unused]] void textInputEvent(TextInputEvent& event) override; + //[[maybe_unused]] void textEditingEvent(TextEditingEvent& event) override; + [[maybe_unused]] void keyPressEvent(KeyEvent& event) override; + [[maybe_unused]] void keyReleaseEvent(KeyEvent& event) override; + [[maybe_unused]] void anyEvent(SDL_Event& event) override; + + void drawEvent() override; + + bool is_text_input_active() const noexcept override; + void start_text_input() noexcept override; + void stop_text_input() noexcept override; + + void debug_callback(unsigned src, unsigned type, unsigned id, unsigned severity, const std::string& str) const; + +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; + + struct draw_bounds final { std::int16_t minx, maxx, miny, maxy; }; + + GL::Framebuffer _msaa_framebuffer{{{}, window_size()}}; + GL::Renderbuffer _msaa_renderbuffer{}; + + void recalc_viewport(Vector2i size) noexcept; + void draw_world() noexcept; + + draw_bounds get_draw_bounds() const noexcept; + + 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); + static Configuration::WindowFlags make_window_flags(const fm_settings& s); +}; + +} // namespace floormat -- cgit v1.2.3