1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-03 09:09:47 +02:00

Update Listener parameters

This commit is contained in:
Filip Gawin 2018-08-12 16:28:13 +02:00
parent 1b1b924d8f
commit 746b8f7d20
3 changed files with 15 additions and 0 deletions

View File

@ -10,6 +10,7 @@ extern "C" {
#include "audio/alCheck.hpp"
#include "engine/GameData.hpp"
#include "engine/GameWorld.hpp"
#include "render/ViewCamera.hpp"
#include <rw/types.hpp>
@ -274,6 +275,14 @@ void SoundManager::pause(bool p) {
}
}
void SoundManager::updateListenerTransform(const ViewCamera& currentCam) {
// @todo ShFil119 it should be improved
_engine->sound.setListenerPosition(currentCam.position);
_engine->sound.setListenerOrientation(glm::vec3(
currentCam.rotation.x, currentCam.rotation.y, currentCam.rotation.z));
//world->sound.setListenerVelocity(glm::vec3());
}
void SoundManager::setListenerPosition(const glm::vec3& position) {
alListener3f(AL_POSITION, position.x, position.y, position.z);
}

View File

@ -19,6 +19,7 @@
#include <loaders/LoaderSDT.hpp>
class GameWorld;
class ViewCamera;
/// Game's sound manager.
/// It handles all stuff connected with sounds.
@ -75,6 +76,9 @@ public:
void playMusic(const std::string& name);
void stopMusic(const std::string& name);
/// Updating listener tranform, called by main loop of game.
void updateListenerTransform(const ViewCamera& currentCam);
/// Setting position of listener for openAL.
void setListenerPosition(const glm::vec3& position);

View File

@ -601,6 +601,8 @@ void RWGame::render(float alpha, float time) {
viewCam.frustum.fov *= viewCam.frustum.aspectRatio;
}
world->sound.updateListenerTransform(viewCam);
glEnable(GL_DEPTH_TEST);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);