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 /loader-impl.cpp | |
| parent | 0e82239a9cf4be27fddd164bf654c6163eb51373 (diff) | |
fix msvc
Diffstat (limited to 'loader-impl.cpp')
| -rw-r--r-- | loader-impl.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
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) |
