diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-03 20:28:33 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-03 20:28:33 +0200 |
| commit | 2bbf13e72c571c5063576a13e123f0ae3ad78f9f (patch) | |
| tree | 12d322d4bcc28be19e4c55f2e30b22af5612b75e | |
| parent | 0e82239a9cf4be27fddd164bf654c6163eb51373 (diff) | |
fix msvc
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | floor-mesh.cpp | 4 | ||||
| -rw-r--r-- | loader-impl.cpp | 11 | ||||
| -rw-r--r-- | tile-atlas.hpp | 4 | ||||
| -rw-r--r-- | wall-mesh.cpp | 2 |
5 files changed, 13 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eb77c3e3..e12d871e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ set_directory_properties(PROPERTIES INTERFACE_CORRADE_CXX_STANDARD 20) set(_userconfig "userconfig-${CMAKE_CXX_COMPILER_ID}.cmake") if(EXISTS "${CMAKE_SOURCE_DIR}/${_userconfig}") - include("${CMAKE_SOURCE_DIR}/${_userconfig}") + include("${CMAKE_SOURCE_DIR}/${_userconfig}" NO_POLICY_SCOPE) else() message(STATUS "user config '${_userconfig}' not found") endif() diff --git a/floor-mesh.cpp b/floor-mesh.cpp index 82a2c61f..964af8bf 100644 --- a/floor-mesh.cpp +++ b/floor-mesh.cpp @@ -67,7 +67,7 @@ static auto make_floor_positions_array() return array; } -const auto floor_mesh::_index_data = make_index_array(); -const auto floor_mesh::_position_data = make_floor_positions_array(); +const decltype(floor_mesh::_index_data) floor_mesh::_index_data = make_index_array(); +const decltype(floor_mesh::_position_data) floor_mesh::_position_data = make_floor_positions_array(); } // namespace Magnum::Examples diff --git a/loader-impl.cpp b/loader-impl.cpp index 5434af76..23552f77 100644 --- a/loader-impl.cpp +++ b/loader-impl.cpp @@ -11,12 +11,13 @@ #include <Magnum/Trade/AbstractImageConverter.h> #include <unordered_map> #include <utility> +#include <optional> namespace Magnum::Examples { struct loader_impl final : loader_ { - const Utility::Resource shader_res{"game/shaders"}; + std::optional<Utility::Resource> shader_res; PluginManager::Manager<Trade::AbstractImporter> importer_plugins; Containers::Pointer<Trade::AbstractImporter> tga_importer = importer_plugins.loadAndInstantiate("AnyImageImporter"); @@ -37,7 +38,9 @@ struct loader_impl final : loader_ std::string loader_impl::shader(const Containers::StringView& filename) { - auto ret = shader_res.getString(filename); + if (!shader_res) + shader_res = std::make_optional<Utility::Resource>("game/shaders"); + auto ret = shader_res->getString(filename); if (ret.isEmpty()) ABORT("can't find shader resource '%s'", filename.cbegin()); return ret; @@ -76,8 +79,8 @@ loader_impl::~loader_impl() = default; static loader_& make_default_loader() { - static loader_impl loader{}; - return loader; + static loader_impl loader_singleton{}; + return loader_singleton; } // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) diff --git a/tile-atlas.hpp b/tile-atlas.hpp index 757c29a6..01dfcb33 100644 --- a/tile-atlas.hpp +++ b/tile-atlas.hpp @@ -17,9 +17,9 @@ struct tile_atlas final static vertex_array_type wall_quad_N(Vector3 center, Vector3 size); static vertex_array_type wall_quad_W(Vector3 center, Vector3 size); static constexpr std::array<UnsignedShort, 6> indices(std::size_t N); + std::size_t size() const { return (std::size_t)dims_.product(); } + Vector2i tile_size() const { return size_ / dims_; } GL::Texture2D& texture() { return tex_; } - constexpr std::size_t size() const { return (std::size_t)dims_.product(); } - constexpr Vector2i tile_size() const { return size_ / dims_; } tile_atlas() = default; tile_atlas(const tile_atlas&) = delete; diff --git a/wall-mesh.cpp b/wall-mesh.cpp index 2dddf3a1..843f7073 100644 --- a/wall-mesh.cpp +++ b/wall-mesh.cpp @@ -75,6 +75,6 @@ decltype(wall_mesh::_index_data) wall_mesh::make_index_array() return array; } -const auto wall_mesh::_index_data = wall_mesh::make_index_array(); +const decltype(wall_mesh::_index_data) wall_mesh::_index_data = wall_mesh::make_index_array(); } // namespace Magnum::Examples |
