From 28f80fa113be3488e98abb9fd6863277d2b94180 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 17 Dec 2007 19:40:43 -0800 Subject: [PATCH] Add AL_METERS_PER_UNIT listener property --- Alc/ALc.c | 1 + Alc/ALu.c | 2 ++ OpenAL32/Include/alListener.h | 1 + OpenAL32/alListener.c | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/Alc/ALc.c b/Alc/ALc.c index f8cf5232..c3dd083e 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -340,6 +340,7 @@ static ALvoid InitContext(ALCcontext *pContext) { //Initialise listener pContext->Listener.Gain = 1.0f; + pContext->Listener.MetersPerUnit = 1.0f; pContext->Listener.Position[0] = 0.0f; pContext->Listener.Position[1] = 0.0f; pContext->Listener.Position[2] = 0.0f; diff --git a/Alc/ALu.c b/Alc/ALu.c index 0821d6b4..92529b4e 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -167,6 +167,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, ALfloat Matrix[3][3]; ALint HeadRelative; ALfloat flAttenuation; + ALfloat MetersPerUnit; //Get context properties DopplerFactor = ALContext->DopplerFactor; @@ -176,6 +177,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, //Get listener properties ListenerGain = ALContext->Listener.Gain; + MetersPerUnit = ALContext->Listener.MetersPerUnit; memcpy(ListenerPosition, ALContext->Listener.Position, sizeof(ALContext->Listener.Position)); memcpy(ListenerVelocity, ALContext->Listener.Velocity, sizeof(ALContext->Listener.Velocity)); memcpy(&ListenerOrientation[0], ALContext->Listener.Forward, sizeof(ALContext->Listener.Forward)); diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 587b2151..d22261fa 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -16,6 +16,7 @@ typedef struct ALlistener_struct ALfloat Forward[3]; ALfloat Up[3]; ALfloat Gain; + ALfloat MetersPerUnit; } ALlistener; #ifdef __cplusplus diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index 97fc593c..1e02622a 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -41,6 +41,13 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue) alSetError(AL_INVALID_VALUE); break; + case AL_METERS_PER_UNIT: + if (flValue > 0.0f) + pContext->Listener.MetersPerUnit = flValue; + else + alSetError(AL_INVALID_VALUE); + break; + default: alSetError(AL_INVALID_ENUM); break; @@ -112,6 +119,13 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) alSetError(AL_INVALID_VALUE); break; + case AL_METERS_PER_UNIT: + if (pflValues[0] > 0.0f) + pContext->Listener.MetersPerUnit = pflValues[0]; + else + alSetError(AL_INVALID_VALUE); + break; + case AL_POSITION: pContext->Listener.Position[0] = pflValues[0]; pContext->Listener.Position[1] = pflValues[1]; @@ -274,6 +288,10 @@ ALAPI ALvoid ALAPIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue) *pflValue = pContext->Listener.Gain; break; + case AL_METERS_PER_UNIT: + *pflValue = pContext->Listener.MetersPerUnit; + break; + default: alSetError(AL_INVALID_ENUM); break; @@ -350,6 +368,10 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues) pflValues[0] = pContext->Listener.Gain; break; + case AL_METERS_PER_UNIT: + pflValues[0] = pContext->Listener.MetersPerUnit; + break; + case AL_POSITION: pflValues[0] = pContext->Listener.Position[0]; pflValues[1] = pContext->Listener.Position[1]; -- 2.11.4.GIT