* Put the SoundSystemAL behind the USE_OPENAL define.

This commit is contained in:
iProgramInCpp
2023-08-08 11:15:30 +03:00
parent cc2dc9b648
commit 0c3099a3d9
2 changed files with 20 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
#ifdef USE_OPENAL
#include "SoundSystemAL.hpp"
#include "client/common/Utils.hpp"
@@ -251,9 +252,18 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
if (volume <= 0.0f)
return;
float distance = Vec3(x, y, z).distanceTo(lastListenerPos);
if (distance >= MAX_DISTANCE)
return;
bool bIsGUI = AL_FALSE;
float distance = 0.0f;
if (x == 0 && y == 0 && z == 0)
{
bIsGUI = AL_TRUE;
}
else
{
distance = Vec3(x, y, z).distanceTo(lastListenerPos);
if (distance >= MAX_DISTANCE)
return;
}
// Load Sound
ALuint buffer = get_buffer(sound);
@@ -286,10 +296,6 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
}
}
bool isUi = AL_FALSE;
if (x == 0 && y == 0 && z == 0)
isUi = AL_TRUE;
// Set Properties
alSourcef(al_source, AL_PITCH, pitch);
AL_ERROR_CHECK();
@@ -301,7 +307,7 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
AL_ERROR_CHECK();
alSourcei(al_source, AL_LOOPING, AL_FALSE);
AL_ERROR_CHECK();
alSourcei(al_source, AL_SOURCE_RELATIVE, isUi);
alSourcei(al_source, AL_SOURCE_RELATIVE, bIsGUI);
AL_ERROR_CHECK();
// Set Attenuation
@@ -321,3 +327,5 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
AL_ERROR_CHECK();
sources.push_back(al_source);
}
#endif

View File

@@ -1,5 +1,7 @@
#pragma once
#ifdef USE_OPENAL
#ifdef _WIN32
#include <thirdparty/OpenAL/Include/al.h>
#include <thirdparty/OpenAL/Include/alc.h>
@@ -44,3 +46,5 @@ private:
Vec3 lastListenerPos;
};
#endif