Merge branch 'master' into LevelSystemAndSuch
This commit is contained in:
@@ -27,14 +27,7 @@ public:
|
|||||||
: System(world, eventBroker) { }
|
: System(world, eventBroker) { }
|
||||||
~SoundSystem();
|
~SoundSystem();
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
|
||||||
//void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
|
||||||
void Update(double dt) override;
|
void Update(double dt) override;
|
||||||
//void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
|
|
||||||
//void OnComponentRemoved(std::string type, Component* component) override;
|
|
||||||
//void PlaySound(Components::SoundEmitter* emitter, std::string path); // Use if you want to play a temporary .wav file not from component
|
|
||||||
//void PlaySound(std::shared_ptr<Components::SoundEmitter> emitter); // Use if you want to play .wav file from component
|
|
||||||
//void StopSound(std::shared_ptr<Components::SoundEmitter> emitter);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -45,13 +38,11 @@ private:
|
|||||||
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
||||||
bool OnPlaySFX(const dd::Events::PlaySFX &event);
|
bool OnPlaySFX(const dd::Events::PlaySFX &event);
|
||||||
bool OnContact(const dd::Events::Contact &event);
|
bool OnContact(const dd::Events::Contact &event);
|
||||||
|
|
||||||
ALuint LoadFile(std::string fileName);
|
|
||||||
ALuint CreateSource();
|
ALuint CreateSource();
|
||||||
|
|
||||||
//std::map<Component*, ALuint> m_Sources;
|
std::map<Component*, ALuint> m_Sources;
|
||||||
|
|
||||||
|
|
||||||
|
//std::list<ALuint>
|
||||||
//Temp
|
//Temp
|
||||||
ALuint m_Source;
|
ALuint m_Source;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ find_package(ZLIB REQUIRED)
|
|||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
find_package(BGFX REQUIRED)
|
find_package(BGFX REQUIRED)
|
||||||
find_package(liquidfun 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)
|
find_package(OpenAL REQUIRED)
|
||||||
|
|
||||||
# GLM
|
# GLM
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ dd::Sound::Sound(std::string path)
|
|||||||
|
|
||||||
ALuint dd::Sound::LoadFile(std::string path)
|
ALuint dd::Sound::LoadFile(std::string path)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG_ERROR("Detta meddelande ska du bara få 1 gång! -----------------------------");
|
|
||||||
if (m_BufferCache.find(path) != m_BufferCache.end()) {
|
if (m_BufferCache.find(path) != m_BufferCache.end()) {
|
||||||
return m_BufferCache[path];
|
return m_BufferCache[path];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
dd::Systems::SoundSystem::~SoundSystem()
|
dd::Systems::SoundSystem::~SoundSystem()
|
||||||
{
|
{
|
||||||
//alDeleteSources(1, m_Source);
|
alSourcei(m_Source, AL_BUFFER, 0);
|
||||||
|
alDeleteSources(1, &m_Source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::SoundSystem::Initialize()
|
void dd::Systems::SoundSystem::Initialize()
|
||||||
@@ -20,9 +21,17 @@ void dd::Systems::SoundSystem::Initialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
alGetError();
|
alGetError();
|
||||||
|
|
||||||
|
//Create source
|
||||||
|
m_Source = CreateSource();
|
||||||
|
|
||||||
alSpeedOfSound(340.29f); // Speed of sound m/s
|
alSpeedOfSound(340.29f); // Speed of sound m/s
|
||||||
alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
|
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
|
//Subscribe to events
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &SoundSystem::OnContact);
|
EVENT_SUBSCRIBE_MEMBER(m_EContact, &SoundSystem::OnContact);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySFX);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySFX);
|
||||||
@@ -30,19 +39,14 @@ void dd::Systems::SoundSystem::Initialize()
|
|||||||
|
|
||||||
void dd::Systems::SoundSystem::Update(double dt)
|
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)
|
bool dd::Systems::SoundSystem::OnPlaySFX(const dd::Events::PlaySFX &event)
|
||||||
{
|
{
|
||||||
m_Source = CreateSource();
|
//m_Source = CreateSource();
|
||||||
//ALuint buffer = LoadFile(event.path); //change to resourcemanager load
|
|
||||||
Sound *sound = ResourceManager::Load<Sound>(event.path);
|
Sound *sound = ResourceManager::Load<Sound>(event.path);
|
||||||
ALuint buffer = sound->Buffer();
|
ALuint buffer = sound->Buffer();
|
||||||
|
|
||||||
alSourcei(m_Source, AL_BUFFER, buffer);
|
alSourcei(m_Source, AL_BUFFER, buffer);
|
||||||
alSourcePlay(m_Source);
|
alSourcePlay(m_Source);
|
||||||
}
|
}
|
||||||
@@ -73,8 +77,3 @@ ALuint dd::Systems::SoundSystem::CreateSource()
|
|||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALuint dd::Systems::SoundSystem::LoadFile(std::string path)
|
|
||||||
{
|
|
||||||
/*Moved code*/
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user