From: Clyne Sullivan Date: Wed, 2 Oct 2019 00:50:28 +0000 (-0400) Subject: Audio component loading, getting ready to play X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=af39f2e08b0503db723ae707a5c7278d8c85f812;p=clyne%2Fgamedev2.git Audio component loading, getting ready to play --- diff --git a/Assets/jump.wav b/Assets/jump.wav new file mode 100644 index 0000000..1cd1681 Binary files /dev/null and b/Assets/jump.wav differ diff --git a/Scripts/init.lua b/Scripts/init.lua index ec9e350..ea5a833 100644 --- a/Scripts/init.lua +++ b/Scripts/init.lua @@ -37,6 +37,9 @@ player = { }, Physics = 0, Name = "bord", + Audio = { + file = "Assets/jump.wav" + }, hellotrue = true, hellofalse = false, Render = { diff --git a/src/audio.cpp b/src/audio.cpp index 975cfce..8bb1413 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -20,13 +20,19 @@ #include "audio.hpp" +#include +#include + AudioSystem::AudioSystem(void) : device(nullptr, [](ALCdevice *d) { alcCloseDevice(d); }), context(nullptr, [](ALCcontext *c) { alcDestroyContext(c); }) {} AudioSystem::~AudioSystem(void) { + alutExit(); + // Delete context before device + alcMakeContextCurrent(nullptr); context.reset(); device.reset(); } @@ -46,6 +52,9 @@ void AudioSystem::configure([[maybe_unused]] entityx::EntityManager& entities, context.reset(alcCreateContext(device.get(), nullptr)); if (!alcMakeContextCurrent(context.get())) return; // TODO Another uh oh + + if (alutInitWithoutContext(nullptr, nullptr) != AL_TRUE) + return; // TODO Third uh oh } void AudioSystem::update([[maybe_unused]] entityx::EntityManager& entities, @@ -56,10 +65,26 @@ void AudioSystem::update([[maybe_unused]] entityx::EntityManager& entities, void AudioSystem::receive(const entityx::ComponentAddedEvent