aboutsummaryrefslogtreecommitdiff
path: root/src/example/asset_manager.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-24 10:52:21 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-24 10:52:21 +0200
commit39054829fa69bcfa2b468015dc3852a2f8deac9f (patch)
treee7726d90fb3c23a15919360dd10bdf709e7e087a /src/example/asset_manager.cpp
parentdd9940720cde6975f79d65e08075687c47f0aec6 (diff)
parent5447ddd896eb49ea9fd9f9191a277fd1d5730aa3 (diff)
merge master into loek/config
Diffstat (limited to 'src/example/asset_manager.cpp')
-rw-r--r--src/example/asset_manager.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/example/asset_manager.cpp b/src/example/asset_manager.cpp
new file mode 100644
index 0000000..7e15d1f
--- /dev/null
+++ b/src/example/asset_manager.cpp
@@ -0,0 +1,39 @@
+
+
+#include <crepe/Sound.h>
+#include <crepe/api/AssetManager.h>
+#include <crepe/api/Texture.h>
+
+using namespace crepe;
+using namespace crepe::api;
+int main() {
+
+ // this needs to be called before the asset manager otherwise the destructor
+ // of sdl is not in the right order
+ { Texture test("../asset/texture/img.png"); }
+ // FIXME: make it so the issue described by the above comment is not possible
+ // (i.e. the order in which internal classes are instantiated should not
+ // impact the way the engine works).
+
+ auto & mgr = AssetManager::get_instance();
+
+ {
+ // TODO: [design] the Sound class can't be directly included by the user as
+ // it includes SoLoud headers.
+ auto bgm = mgr.cache<Sound>("../mwe/audio/bgm.ogg");
+ auto sfx1 = mgr.cache<Sound>("../mwe/audio/sfx1.wav");
+ auto sfx2 = mgr.cache<Sound>("../mwe/audio/sfx2.wav");
+
+ auto img = mgr.cache<Texture>("../asset/texture/img.png");
+ auto img1 = mgr.cache<Texture>("../asset/texture/second.png");
+ }
+
+ {
+ auto bgm = mgr.cache<Sound>("../mwe/audio/bgm.ogg");
+ auto sfx1 = mgr.cache<Sound>("../mwe/audio/sfx1.wav");
+ auto sfx2 = mgr.cache<Sound>("../mwe/audio/sfx2.wav");
+
+ auto img = mgr.cache<Texture>("../asset/texture/img.png");
+ auto img1 = mgr.cache<Texture>("../asset/texture/second.png");
+ }
+}