sound set volume
This commit is contained in:
parent
8d9c74bc4f
commit
cbe1374b03
3 changed files with 8 additions and 2 deletions
|
@ -18,7 +18,6 @@ XeSound::XeSound(const std::string& filename) {
|
||||||
alSource3f(source, AL_VELOCITY, 0, 0, 0);
|
alSource3f(source, AL_VELOCITY, 0, 0, 0);
|
||||||
alSourcei(source, AL_LOOPING, AL_FALSE);
|
alSourcei(source, AL_LOOPING, AL_FALSE);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, buffer);
|
||||||
alSourcef(source, AL_GAIN, 3.f);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,4 +57,8 @@ void XeSound::setLooping(bool looping) {
|
||||||
alSourcei(source, AL_LOOPING, looping ? 1 : 0);
|
alSourcei(source, AL_LOOPING, looping ? 1 : 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void XeSound::setVolume(float volume) {
|
||||||
|
alSourcef(source, AL_GAIN, volume);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -27,6 +27,7 @@ class XeSound {
|
||||||
|
|
||||||
void setPosition(glm::vec3 position);
|
void setPosition(glm::vec3 position);
|
||||||
void setLooping(bool looping);
|
void setLooping(bool looping);
|
||||||
|
void setVolume(float volume);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ALuint source;
|
ALuint source;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
FirstApp::FirstApp() : xeEngine{WIDTH, HEIGHT, "Hello, Vulkan!"} {
|
FirstApp::FirstApp() : xeEngine{WIDTH, HEIGHT, "Xenon Vulkan Engine"} {
|
||||||
loadGameObjects();
|
loadGameObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ void FirstApp::run() {
|
||||||
SimpleRenderer renderer{xeEngine, image.get()};
|
SimpleRenderer renderer{xeEngine, image.get()};
|
||||||
|
|
||||||
xe::XeSound sound{"res/sound/when_the_world_ends.wav"};
|
xe::XeSound sound{"res/sound/when_the_world_ends.wav"};
|
||||||
|
sound.setLooping(true);
|
||||||
sound.play();
|
sound.play();
|
||||||
|
|
||||||
auto viewerObject = xe::XeGameObject::createGameObject();
|
auto viewerObject = xe::XeGameObject::createGameObject();
|
||||||
|
@ -51,6 +52,7 @@ void FirstApp::run() {
|
||||||
renderer.render(gameObjects, xeEngine.getCamera(), image2.get());
|
renderer.render(gameObjects, xeEngine.getCamera(), image2.get());
|
||||||
xeEngine.endFrame();
|
xeEngine.endFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xeEngine.close();
|
xeEngine.close();
|
||||||
|
|
Loading…
Reference in a new issue