diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-23 19:13:21 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-23 19:13:21 +0200 |
commit | fe5cdbe0fa48e14154be89e89e041a02f842d3b1 (patch) | |
tree | 633e086fc67bcffb7f7f63c3d284ec2097d76f34 | |
parent | ed0b81dcbdd718e55a9d09b6da54950c664be9c3 (diff) |
a
-rw-r--r-- | main/floormat-events.cpp | 15 | ||||
-rw-r--r-- | main/floormat-main-impl.cpp | 35 | ||||
-rw-r--r-- | main/floormat-main.hpp | 5 | ||||
-rw-r--r-- | main/floormat.hpp | 2 |
4 files changed, 41 insertions, 16 deletions
diff --git a/main/floormat-events.cpp b/main/floormat-events.cpp index 55fb7a91..8d5fa61a 100644 --- a/main/floormat-events.cpp +++ b/main/floormat-events.cpp @@ -1,5 +1,7 @@ #pragma once -#include "floormat-main.hpp" +#include "floormat-main-impl.hpp" +#include "floormat-app.hpp" +#include "floormat-events.hpp" #include "compat/assert.hpp" #include <SDL_events.h> #include <SDL_video.h> @@ -10,19 +12,14 @@ void main_impl::viewportEvent(Platform::Sdl2Application::ViewportEvent& event) { fm_assert(event.framebufferSize() == event.windowSize()); recalc_viewport(event.windowSize()); - app.viewport_event(event.windowSize()); + app.on_viewport_event(event.windowSize()); } void main_impl::mousePressEvent(Platform::Sdl2Application::MouseEvent& event) { - if (app.) - if (_imgui.handleMousePressEvent(event)) + event. + if (app.on_mouse_down()) return event.setAccepted(); - else if (_cursor_tile) - { - const auto& tile = *_cursor_tile; - do_mouse_click(tile, (int)event.button()); - } } void main_impl::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event) diff --git a/main/floormat-main-impl.cpp b/main/floormat-main-impl.cpp index 85fd5cb9..61dc40b4 100644 --- a/main/floormat-main-impl.cpp +++ b/main/floormat-main-impl.cpp @@ -6,6 +6,7 @@ #include "src/chunk.hpp" #include "src/world.hpp" #include "src/camera-offset.hpp" +#include <cstdlib> //#define FM_SKIP_MSAA @@ -36,10 +37,34 @@ auto main_impl::make_window_flags(const fm_options& s) -> Configuration::WindowF auto main_impl::make_conf(const fm_options& 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)); + .setTitle(s.title) + .setSize(s.resolution) + .setWindowFlags(make_window_flags(s)); +} + +auto main_impl::make_gl_conf(const fm_options& s) -> GLConfiguration +{ + GLConfiguration::Flags flags{}; + using f = GLConfiguration::Flag; + if (s.gpu_debug == fm_gpu_debug::on || s.gpu_debug == fm_gpu_debug::robust) + 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; } void main_impl::recalc_viewport(Vector2i size) noexcept @@ -52,7 +77,7 @@ void main_impl::recalc_viewport(Vector2i size) noexcept _msaa_framebuffer.setViewport({{}, size }); _msaa_framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _msaa_renderbuffer); #endif - _shader.set_scale(Vector2(size)); + _shader.set_scale(Vector2{size}); app.on_viewport_event(size); } @@ -183,7 +208,7 @@ void main_impl::quit(int status) } Vector2i main_impl::window_size() const noexcept { return windowSize(); } -tile_shader& shader() noexcept { return _shader; } +tile_shader& main_impl::shader() noexcept { return _shader; } floormat_main* floormat_main::create(floormat_app& app, const fm_options& options) { diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp index 7b984781..ae08744e 100644 --- a/main/floormat-main.hpp +++ b/main/floormat-main.hpp @@ -25,7 +25,7 @@ struct floormat_main virtual Magnum::Math::Vector2<int> window_size() const noexcept = 0; virtual tile_shader& shader() noexcept = 0; virtual void register_debug_callback() noexcept = 0; - constexpr float smoothed_dt() const noexcept { return _smoothed_dt; } + constexpr float smoothed_dt() const noexcept { return _frame_time; } virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0; @@ -33,6 +33,9 @@ struct floormat_main virtual SDL_Window* window() noexcept = 0; static floormat_main* create(floormat_app& app, const fm_options& options); + +protected: + float _frame_time = 0; }; } // namespace floormat diff --git a/main/floormat.hpp b/main/floormat.hpp index 49b7ec76..cc73c459 100644 --- a/main/floormat.hpp +++ b/main/floormat.hpp @@ -5,7 +5,7 @@ namespace floormat { -enum class fm_gpu_debug : char { no_error = -1, on, off }; +enum class fm_gpu_debug : char { no_error = -1, on, robust, off }; enum class fm_tristate : char { maybe = -1, on, off }; enum class fm_log_level : unsigned char { quiet, normal, verbose, }; |