aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/crepe/Sound.cpp6
-rw-r--r--src/crepe/Sound.h6
-rw-r--r--src/crepe/api/Asset.cpp14
-rw-r--r--src/crepe/api/Asset.h (renamed from src/crepe/api/Resource.h)4
-rw-r--r--src/crepe/api/AudioSource.cpp2
-rw-r--r--src/crepe/api/AudioSource.h6
-rw-r--r--src/crepe/api/CMakeLists.txt4
-rw-r--r--src/crepe/api/Resource.cpp14
-rw-r--r--src/test/audio.cpp4
9 files changed, 30 insertions, 30 deletions
diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp
index 1758282..c6e87d5 100644
--- a/src/crepe/Sound.cpp
+++ b/src/crepe/Sound.cpp
@@ -5,17 +5,17 @@
using namespace crepe;
-Sound::Sound(std::unique_ptr<api::Resource> res) {
+Sound::Sound(std::unique_ptr<api::Asset> res) {
dbg_trace();
this->load(std::move(res));
}
Sound::Sound(const char * src) {
dbg_trace();
- this->load(std::make_unique<api::Resource>(src));
+ this->load(std::make_unique<api::Asset>(src));
}
-void Sound::load(std::unique_ptr<api::Resource> res) {
+void Sound::load(std::unique_ptr<api::Asset> res) {
this->sample.load(res->canonical());
}
diff --git a/src/crepe/Sound.h b/src/crepe/Sound.h
index ac93991..339dd7c 100644
--- a/src/crepe/Sound.h
+++ b/src/crepe/Sound.h
@@ -5,7 +5,7 @@
#include <memory>
-#include "api/Resource.h"
+#include "api/Asset.h"
namespace crepe {
@@ -66,10 +66,10 @@ public:
public:
Sound(const char * src);
- Sound(std::unique_ptr<api::Resource> res);
+ Sound(std::unique_ptr<api::Asset> res);
private:
- void load(std::unique_ptr<api::Resource> res);
+ void load(std::unique_ptr<api::Asset> res);
private:
SoLoud::Wav sample;
diff --git a/src/crepe/api/Asset.cpp b/src/crepe/api/Asset.cpp
new file mode 100644
index 0000000..92ee50e
--- /dev/null
+++ b/src/crepe/api/Asset.cpp
@@ -0,0 +1,14 @@
+#include <filesystem>
+
+#include "Asset.h"
+
+using namespace crepe::api;
+
+Asset::Asset(const std::string & src) {
+ this->src = std::filesystem::canonical(src);
+ this->file = std::ifstream(this->src, std::ios::in | std::ios::binary);
+}
+
+const std::istream & Asset::read() { return this->file; }
+
+const char * Asset::canonical() { return this->src.c_str(); }
diff --git a/src/crepe/api/Resource.h b/src/crepe/api/Asset.h
index f2b2a0e..259c696 100644
--- a/src/crepe/api/Resource.h
+++ b/src/crepe/api/Asset.h
@@ -6,9 +6,9 @@
namespace crepe::api {
-class Resource {
+class Asset {
public:
- Resource(const std::string & src);
+ Asset(const std::string & src);
public:
//! Get an input stream to the contents of this resource
diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp
index 4d1b093..656fc46 100644
--- a/src/crepe/api/AudioSource.cpp
+++ b/src/crepe/api/AudioSource.cpp
@@ -5,7 +5,7 @@
using namespace crepe::api;
-AudioSource::AudioSource(std::unique_ptr<Resource> audio_clip) {
+AudioSource::AudioSource(std::unique_ptr<Asset> audio_clip) {
this->_sound = std::make_unique<crepe::Sound>(std::move(audio_clip));
}
diff --git a/src/crepe/api/AudioSource.h b/src/crepe/api/AudioSource.h
index 4300c48..9dfaf46 100644
--- a/src/crepe/api/AudioSource.h
+++ b/src/crepe/api/AudioSource.h
@@ -3,7 +3,7 @@
#include <memory>
#include "Component.h"
-#include "Resource.h"
+#include "Asset.h"
namespace crepe {
class Sound;
@@ -14,7 +14,7 @@ namespace crepe::api {
//! Audio source component
class AudioSource : Component {
public:
- AudioSource(std::unique_ptr<Resource> audio_clip);
+ AudioSource(std::unique_ptr<Asset> audio_clip);
virtual ~AudioSource() = default;
public:
@@ -26,7 +26,7 @@ public:
public:
//! Sample file location
- std::unique_ptr<Resource> audio_clip;
+ std::unique_ptr<Asset> audio_clip;
//! TODO: ?????
bool play_on_awake;
//! Repeat the current audio clip during playback
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index feb03ef..54c7fdc 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -1,11 +1,11 @@
target_sources(crepe PUBLIC
# AudioSource.cpp
- Resource.cpp
+ Asset.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
AudioSource.h
Component.h
- Resource.h
+ Asset.h
)
diff --git a/src/crepe/api/Resource.cpp b/src/crepe/api/Resource.cpp
deleted file mode 100644
index 1a647ce..0000000
--- a/src/crepe/api/Resource.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <filesystem>
-
-#include "Resource.h"
-
-using namespace crepe::api;
-
-Resource::Resource(const std::string & src) {
- this->src = std::filesystem::canonical(src);
- this->file = std::ifstream(this->src, std::ios::in | std::ios::binary);
-}
-
-const std::istream & Resource::read() { return this->file; }
-
-const char * Resource::canonical() { return this->src.c_str(); }
diff --git a/src/test/audio.cpp b/src/test/audio.cpp
index 5bb2607..1d84551 100644
--- a/src/test/audio.cpp
+++ b/src/test/audio.cpp
@@ -2,7 +2,7 @@
#include <memory>
#include <crepe/api/AudioSource.h>
-#include <crepe/api/Resource.h>
+#include <crepe/api/Asset.h>
#include <chrono>
#include <thread>
@@ -15,7 +15,7 @@ using namespace crepe::api;
// TODO: mock internal audio class
TEST(audio, play) {
- auto res = std::make_unique<Resource>("../mwe/audio/bgm.ogg");
+ auto res = std::make_unique<Asset>("../mwe/audio/bgm.ogg");
auto bgm = AudioSource(std::move(res));
bgm.play();