mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 15:02:34 +02:00
Update Listener parameters
This commit is contained in:
parent
1b1b924d8f
commit
746b8f7d20
@ -10,6 +10,7 @@ extern "C" {
|
|||||||
#include "audio/alCheck.hpp"
|
#include "audio/alCheck.hpp"
|
||||||
#include "engine/GameData.hpp"
|
#include "engine/GameData.hpp"
|
||||||
#include "engine/GameWorld.hpp"
|
#include "engine/GameWorld.hpp"
|
||||||
|
#include "render/ViewCamera.hpp"
|
||||||
|
|
||||||
#include <rw/types.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) {
|
void SoundManager::setListenerPosition(const glm::vec3& position) {
|
||||||
alListener3f(AL_POSITION, position.x, position.y, position.z);
|
alListener3f(AL_POSITION, position.x, position.y, position.z);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <loaders/LoaderSDT.hpp>
|
#include <loaders/LoaderSDT.hpp>
|
||||||
|
|
||||||
class GameWorld;
|
class GameWorld;
|
||||||
|
class ViewCamera;
|
||||||
|
|
||||||
/// Game's sound manager.
|
/// Game's sound manager.
|
||||||
/// It handles all stuff connected with sounds.
|
/// It handles all stuff connected with sounds.
|
||||||
@ -75,6 +76,9 @@ public:
|
|||||||
void playMusic(const std::string& name);
|
void playMusic(const std::string& name);
|
||||||
void stopMusic(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.
|
/// Setting position of listener for openAL.
|
||||||
void setListenerPosition(const glm::vec3& position);
|
void setListenerPosition(const glm::vec3& position);
|
||||||
|
|
||||||
|
@ -601,6 +601,8 @@ void RWGame::render(float alpha, float time) {
|
|||||||
viewCam.frustum.fov *= viewCam.frustum.aspectRatio;
|
viewCam.frustum.fov *= viewCam.frustum.aspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world->sound.updateListenerTransform(viewCam);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user