diff options
author | erihel <erihel@gmail.com> | 2013-04-07 13:35:39 +0200 |
---|---|---|
committer | erihel <erihel@gmail.com> | 2013-04-07 13:35:39 +0200 |
commit | f4b1cabbde0187c7429e31ff344814adf35c4bc1 (patch) | |
tree | f2dda352f193b826e6b594e7907e529bcf158d56 | |
parent | 926126d5adf457dbc5c92fd83c7231415ea22d04 (diff) | |
download | colobot-f4b1cabbde0187c7429e31ff344814adf35c4bc1.tar.gz colobot-f4b1cabbde0187c7429e31ff344814adf35c4bc1.tar.bz2 colobot-f4b1cabbde0187c7429e31ff344814adf35c4bc1.zip |
* Sound are too quiet in 3D mode, for now added support for 2D sound option in menu. In 2D mode sounds are normal (Issue #123)
-rw-r--r-- | src/sound/oalsound/alsound.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index e3a3f4b..660363e 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -92,15 +92,25 @@ bool ALSound::Create(bool b3D) void ALSound::SetSound3D(bool bMode) { - // TODO stub! need to be implemented m3D = bMode; + + if (!m3D) { + float orientation[] = {0.0f, 0.0f, 0.0f, 0.f, 1.f, 0.f}; + alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); + alListenerfv(AL_ORIENTATION, orientation); + + for (auto c : mChannels) { + if (c.second->IsPlaying()) { + c.second->SetPosition(Math::Vector(0.0f, 0.0f, 0.0f)); + } + } + } } bool ALSound::GetSound3D() { - // TODO stub! need to be implemented - return true; + return m3D; } @@ -371,7 +381,9 @@ bool ALSound::Position(int channel, Math::Vector pos) return false; } - mChannels[channel]->SetPosition(pos); + if (m3D) { + mChannels[channel]->SetPosition(pos); + } return true; } @@ -494,9 +506,11 @@ void ALSound::FrameMove(float delta) void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) { - float orientation[] = {lookat.x, lookat.y, lookat.z, 0.f, 1.f, 0.f}; - alListener3f(AL_POSITION, eye.x, eye.y, eye.z); - alListenerfv(AL_ORIENTATION, orientation); + if (m3D) { + float orientation[] = {lookat.x, lookat.y, lookat.z, 0.f, 1.f, 0.f}; + alListener3f(AL_POSITION, eye.x, eye.y, eye.z); + alListenerfv(AL_ORIENTATION, orientation); + } } |