diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2019-10-01 20:50:28 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2019-10-01 20:50:28 -0400 |
commit | af39f2e08b0503db723ae707a5c7278d8c85f812 (patch) | |
tree | ad6ab6e51e1a7e30d72a28e2bac51b210fd22f6c /src/components/Audio.hpp | |
parent | bebc6e955114a0907c43df9a9c00f22b1f743446 (diff) |
Audio component loading, getting ready to play
Diffstat (limited to 'src/components/Audio.hpp')
-rw-r--r-- | src/components/Audio.hpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/components/Audio.hpp b/src/components/Audio.hpp index 3f7296d..a97b235 100644 --- a/src/components/Audio.hpp +++ b/src/components/Audio.hpp @@ -24,14 +24,23 @@ struct Audio : Component<Audio> { public: + std::string fileName; ALuint source; + ALuint buffer; - Audio(ALuint _source = 0) : - source(_source) {} + Audio(std::string _fileName = "") : + fileName(_fileName), source(0), buffer(0) {} - Audio FromLua([[maybe_unused]] sol::object ref) + Audio FromLua(sol::object ref) { - // TODO load from file name? + if (ref.get_type() == sol::type::table) { + sol::table tab = ref; + if (tab["file"] != nullptr) + this->fileName = tab["file"]; + } else { + throw std::string("Audio table not formatted properly"); + } + return *this; } |