diff options
Diffstat (limited to 'main')
| -rw-r--r-- | main/ctor.cpp | 34 | ||||
| -rw-r--r-- | main/draw.cpp | 3 | ||||
| -rw-r--r-- | main/main-impl.cpp | 2 | ||||
| -rw-r--r-- | main/main-impl.hpp | 7 | ||||
| -rw-r--r-- | main/setup.cpp | 27 |
5 files changed, 40 insertions, 33 deletions
diff --git a/main/ctor.cpp b/main/ctor.cpp new file mode 100644 index 00000000..11bc8cb9 --- /dev/null +++ b/main/ctor.cpp @@ -0,0 +1,34 @@ +#include "main-impl.hpp" +#include "compat/fpu.hpp" +#include "src/path-search.hpp" +#include <Corrade/Containers/GrowableArray.h> + +namespace floormat { + +main_impl::main_impl(floormat_app& app, fm_settings&& se, int& argc, char** argv) noexcept : + Platform::Sdl2Application{Arguments{argc, argv}, + make_conf(se), make_gl_conf(se)}, + s{std::move(se)}, app{app}, _shader{_tuc} +{ + if (s.vsync) + { + (void)setSwapInterval(1); + if (const auto list = GL::Context::current().extensionStrings(); + std::find(list.cbegin(), list.cend(), "EXT_swap_control_tear") != list.cend()) + (void)setSwapInterval(-1); + } + else + (void)setSwapInterval(0); + set_fp_mask(); + arrayReserve(_clickable_scenery, 128); + timeline.start(); +} + +class world& main_impl::reset_world(class world&& w) noexcept +{ + arrayResize(_clickable_scenery, 0); + _world = std::move(w); + return _world; +} + +} // namespace floormat diff --git a/main/draw.cpp b/main/draw.cpp index 4de42473..dc476fe8 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -4,6 +4,7 @@ #include "src/anim-atlas.hpp" #include "main/clickable.hpp" #include "src/light.hpp" +#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/ArrayView.h> #include <Magnum/GL/DefaultFramebuffer.h> #include <Magnum/GL/Renderer.h> @@ -134,7 +135,7 @@ void main_impl::draw_world() noexcept fm_debug_assert(1 + maxx - minx <= 8); fm_debug_assert(1 + maxy - miny <= 8); - _clickable_scenery.clear(); + arrayResize(_clickable_scenery, 0); #ifdef FM_USE_DEPTH32 framebuffer.fb.clearDepth(0); #else diff --git a/main/main-impl.cpp b/main/main-impl.cpp index 6875f751..0ce2b5fb 100644 --- a/main/main-impl.cpp +++ b/main/main-impl.cpp @@ -65,6 +65,6 @@ uint32_t main_impl::cursor() const noexcept struct texture_unit_cache& main_impl::texture_unit_cache() { return _tuc; } path_search& main_impl::search() { return *_search; } -astar& main_impl::astar() { return _astar; } +astar& main_impl::astar() { return *_astar; } } // namespace floormat diff --git a/main/main-impl.hpp b/main/main-impl.hpp index 522183e6..ecfa17f7 100644 --- a/main/main-impl.hpp +++ b/main/main-impl.hpp @@ -9,8 +9,7 @@ #include "shaders/shader.hpp" #include "shaders/lightmap.hpp" #include "main/clickable.hpp" -#include "src/path-search.hpp" -#include <vector> +#include <Corrade/Containers/Array.h> #include <Corrade/Containers/String.h> #include <Magnum/Timeline.h> #include <Magnum/Math/Range.h> @@ -109,7 +108,7 @@ private: floormat_app& app; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) tile_shader _shader; struct lightmap_shader _lightmap_shader{_tuc}; - std::vector<clickable> _clickable_scenery; + Array<clickable> _clickable_scenery; class world _world{}; Magnum::Timeline timeline; uint32_t _mouse_cursor = (uint32_t)-1; @@ -120,7 +119,7 @@ private: Framebuffer framebuffer; #endif safe_ptr<path_search> _search; - class astar _astar; + safe_ptr<class astar> _astar; struct { float value = 0; diff --git a/main/setup.cpp b/main/setup.cpp index 6f794719..797fbfb0 100644 --- a/main/setup.cpp +++ b/main/setup.cpp @@ -1,30 +1,10 @@ #include "main-impl.hpp" -#include "compat/fpu.hpp" #include <algorithm> #include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringIterable.h> namespace floormat { -main_impl::main_impl(floormat_app& app, fm_settings&& se, int& argc, char** argv) noexcept : - Platform::Sdl2Application{Arguments{argc, argv}, - make_conf(se), make_gl_conf(se)}, - s{std::move(se)}, app{app}, _shader{_tuc} -{ - if (s.vsync) - { - (void)setSwapInterval(1); - if (const auto list = GL::Context::current().extensionStrings(); - std::find(list.cbegin(), list.cend(), "EXT_swap_control_tear") != list.cend()) - (void)setSwapInterval(-1); - } - else - (void)setSwapInterval(0); - set_fp_mask(); - _clickable_scenery.reserve(128); - timeline.start(); -} - auto main_impl::make_window_flags(const fm_settings& s) -> Configuration::WindowFlags { using flag = Configuration::WindowFlag; @@ -108,11 +88,4 @@ class world& main_impl::reset_world() noexcept return reset_world(floormat::world{}); } -class world& main_impl::reset_world(class world&& w) noexcept -{ - _clickable_scenery.clear(); - _world = std::move(w); - return _world; -} - } // namespace floormat |
