diff options
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | Alc/ALu.c | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 1 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 27 | ||||
-rw-r--r-- | OpenAL32/alState.c | 4 |
5 files changed, 31 insertions, 5 deletions
@@ -475,7 +475,7 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->lNumStereoSources = 1; pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources; - pContext->ExtensionList = "AL_EXTX_buffer_sub_data AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_LOKI_quadriphonic"; + pContext->ExtensionList = "AL_EXTX_buffer_sub_data AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_EXTX_source_distance_model AL_LOKI_quadriphonic"; level = GetConfigValueInt(NULL, "cf_level", 0); if(level > 0 && level <= 6) @@ -324,7 +324,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, flAttenuation = 1.0f; RoomAttenuation = 1.0f; - switch (ALContext->DistanceModel) + switch (ALSource->DistanceModel) { case AL_INVERSE_DISTANCE_CLAMPED: Distance=__max(Distance,MinDist); diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 617dc4e3..b79f43d6 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -48,6 +48,7 @@ typedef struct ALsource ALfloat vOrientation[3]; ALboolean bHeadRelative; ALboolean bLooping; + ALenum DistanceModel; ALuint ulBufferID; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index e130e044..f1ce4e85 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -32,7 +32,7 @@ #include "alThunk.h" #include "alAuxEffectSlot.h" -static ALvoid InitSourceParams(ALsource *pSource); +static ALvoid InitSourceParams(ALCcontext *Context, ALsource *pSource); static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOffset, ALuint updateSize); static ALvoid ApplyOffset(ALsource *pSource, ALboolean bUpdateContext); static ALint GetByteOffset(ALsource *pSource); @@ -78,7 +78,7 @@ ALAPI ALvoid ALAPIENTRY alGenSources(ALsizei n,ALuint *sources) sources[i] = (ALuint)ALTHUNK_ADDENTRY(*list); (*list)->source = sources[i]; - InitSourceParams(*list); + InitSourceParams(Context, *list); Context->SourceCount++; i++; @@ -704,6 +704,19 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) alSetError(AL_INVALID_VALUE); break; + case AL_DISTANCE_MODEL: + if(lValue == AL_NONE || + lValue == AL_INVERSE_DISTANCE || + lValue == AL_INVERSE_DISTANCE_CLAMPED || + lValue == AL_LINEAR_DISTANCE || + lValue == AL_LINEAR_DISTANCE_CLAMPED || + lValue == AL_EXPONENT_DISTANCE || + lValue == AL_EXPONENT_DISTANCE_CLAMPED) + pSource->DistanceModel = lValue; + else + alSetError(AL_INVALID_VALUE); + break; + default: alSetError(AL_INVALID_ENUM); break; @@ -819,6 +832,7 @@ ALAPI void ALAPIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* plVa case AL_DIRECT_FILTER_GAINHF_AUTO: case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: + case AL_DISTANCE_MODEL: alSourcei(source, eParam, plValues[0]); break; @@ -1212,6 +1226,10 @@ ALAPI ALvoid ALAPIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValu *plValue = (ALint)pSource->DopplerFactor; break; + case AL_DISTANCE_MODEL: + *plValue = pSource->DistanceModel; + break; + default: alSetError(AL_INVALID_ENUM); break; @@ -1326,6 +1344,7 @@ ALAPI void ALAPIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plValue case AL_DIRECT_FILTER_GAINHF_AUTO: case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: + case AL_DISTANCE_MODEL: alGetSourcei(source, eParam, plValues); break; @@ -1979,7 +1998,7 @@ ALAPI ALvoid ALAPIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint } -static ALvoid InitSourceParams(ALsource *pSource) +static ALvoid InitSourceParams(ALCcontext *Context, ALsource *pSource) { pSource->flInnerAngle = 360.0f; pSource->flOuterAngle = 360.0f; @@ -2010,6 +2029,8 @@ static ALvoid InitSourceParams(ALsource *pSource) pSource->RoomRolloffFactor = 0.0f; pSource->DopplerFactor = 1.0f; + pSource->DistanceModel = Context->DistanceModel; + pSource->state = AL_INITIAL; pSource->lSourceType = AL_UNDETERMINED; diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 0a01dc37..8ca5a012 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -24,6 +24,7 @@ #include "alMain.h" #include "AL/alc.h" #include "alError.h" +#include "alSource.h" #include "alState.h" static const ALchar alVendor[] = "OpenAL Community"; @@ -644,6 +645,7 @@ ALAPI ALvoid ALAPIENTRY alSpeedOfSound(ALfloat flSpeedOfSound) ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value) { ALCcontext *Context; + ALsource *Source; Context=alcGetCurrentContext(); if (Context) @@ -660,6 +662,8 @@ ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value) case AL_EXPONENT_DISTANCE: case AL_EXPONENT_DISTANCE_CLAMPED: Context->DistanceModel = value; + for(Source = Context->Source;Source != NULL;Source = Source->next) + Source->DistanceModel = value; break; default: |