OpenAL fixed. CMake path set correctly.

This commit is contained in:
Stiffly
2015-09-22 14:32:04 +02:00
parent 7e9e19039c
commit 3f4ede4b7d
3 changed files with 13 additions and 6 deletions
+2 -2
View File
@@ -40,9 +40,9 @@ private:
bool OnContact(const dd::Events::Contact &event);
ALuint CreateSource();
//std::map<Component*, ALuint> m_Sources;
std::map<Component*, ALuint> m_Sources;
//std::list<ALuint>
//Temp
ALuint m_Source;
+2
View File
@@ -9,6 +9,8 @@ find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(BGFX REQUIRED)
find_package(liquidfun REQUIRED)
# Because FindOpenAL is retarded
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/deps/include/AL")
find_package(OpenAL REQUIRED)
# GLM
+9 -4
View File
@@ -21,9 +21,17 @@ void dd::Systems::SoundSystem::Initialize()
}
alGetError();
//Create source
m_Source = CreateSource();
alSpeedOfSound(340.29f); // Speed of sound m/s
alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
const ALfloat pos[3] = {0, 0, 0};
alListenerfv(AL_POSITION, pos);
alSourcefv(m_Source, AL_POSITION, pos);
//Subscribe to events
EVENT_SUBSCRIBE_MEMBER(m_EContact, &SoundSystem::OnContact);
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySFX);
@@ -31,15 +39,12 @@ void dd::Systems::SoundSystem::Initialize()
void dd::Systems::SoundSystem::Update(double dt)
{
const ALfloat pos[3] = {0, 0, 0};
alListenerfv(AL_POSITION, pos);
alSourcefv(m_Source, AL_POSITION, pos);
}
bool dd::Systems::SoundSystem::OnPlaySFX(const dd::Events::PlaySFX &event)
{
m_Source = CreateSource();
//m_Source = CreateSource();
Sound *sound = ResourceManager::Load<Sound>(event.path);
ALuint buffer = sound->Buffer();
alSourcei(m_Source, AL_BUFFER, buffer);