From e4c443042b846aa93a9be0414deeffadaac42762 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Mar 2014 18:08:56 +0100 Subject: [PATCH] =?UTF-8?q?SoundSystem=20p=C3=A5b=C3=B6rjat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Escape-the-Dawn/Components/SoundEmitter.h | 1 - Escape-the-Dawn/Escape-the-Dawn.vcxproj | 13 ++----- Escape-the-Dawn/Systems/SoundSystem.h | 29 ++++++++++++++++ Escape-the-Dawn/Systems/SoundsSystem.cpp | 41 +++++++++++++++++++++++ 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/Escape-the-Dawn/Components/SoundEmitter.h b/Escape-the-Dawn/Components/SoundEmitter.h index 01772cd..441afe0 100644 --- a/Escape-the-Dawn/Components/SoundEmitter.h +++ b/Escape-the-Dawn/Components/SoundEmitter.h @@ -10,7 +10,6 @@ namespace Components struct SoundEmitter : Component { - std::string SoundFile; float Volume; float MaxRange; }; diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj b/Escape-the-Dawn/Escape-the-Dawn.vcxproj index 4fbe3f4..b4ee946 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj @@ -40,14 +40,17 @@ + $(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath) $(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath) $(SolutionDir)bin\ $(SolutionDir)obj\$(ProjectName)\ $(ProjectName)-$(Configuration) + $(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath) @@ -98,16 +101,11 @@ - - - - - @@ -135,13 +133,9 @@ - - - - @@ -154,7 +148,6 @@ - diff --git a/Escape-the-Dawn/Systems/SoundSystem.h b/Escape-the-Dawn/Systems/SoundSystem.h index e69de29..f6e8acc 100644 --- a/Escape-the-Dawn/Systems/SoundSystem.h +++ b/Escape-the-Dawn/Systems/SoundSystem.h @@ -0,0 +1,29 @@ +#ifndef SoundEmitter_h__ +#define SoundEmitter_h__ + +#include "System.h" +#include "Components/SoundEmitter.h" + +namespace System +{ + +class SoundSystem : public System +{ +public: + SoundSystem(World* world) : System(world) + { + + } + void Update(double dt) override; + void Update(double dt, EntityID entity, EntityID parent) override; + void OnComponentCreated(std::string type, std::shared_ptr component) override; + void PlaySound(std::shared_ptr emitter, std::string fileName); + void LoadFile(std::string fileName); +private: + ALCcontext* context; + +}; + +} +#endif // !SoundEmitter_h__ + diff --git a/Escape-the-Dawn/Systems/SoundsSystem.cpp b/Escape-the-Dawn/Systems/SoundsSystem.cpp index e69de29..8dd2ef4 100644 --- a/Escape-the-Dawn/Systems/SoundsSystem.cpp +++ b/Escape-the-Dawn/Systems/SoundsSystem.cpp @@ -0,0 +1,41 @@ +#include "SoundSystem.h" +#include "World.h" +#include +#include + +System::SoundSystem::SoundSystem(World* world) +{ + ALCdevice* Device = alcOpenDevice(nullptr); + + if(Device) + { + context = alcCreateContext(Device, nullptr); + alcMakeContextCurrent(context); + } + + +} + +void System::SoundSystem::Update(double dt) +{ + +} + +void System::SoundSystem::Update(double dt, EntityID entity, EntityID parent) +{ + auto soundEmitter = m_World->GetComponent(entity, "SoundEmitter"); + if(soundEmitter == nullptr) + return; + + +} + +void System::SoundSystem::PlaySound(std::shared_ptr emitter, std::string fileName) +{ + LoadFile(fileName); +} + +void System::SoundSystem::LoadFile(std::string fileName) +{ + loadWavFile() +} \ No newline at end of file