Update AL_EXTX_source_distance_model to require explicit enabling
The in-progress spec has been updated to reflect this
This commit is contained in:
parent
69f9ab88b9
commit
98ce1d14c1
@ -561,6 +561,7 @@ static ALvoid InitContext(ALCcontext *pContext)
|
||||
|
||||
//Set globals
|
||||
pContext->DistanceModel = AL_INVERSE_DISTANCE_CLAMPED;
|
||||
pContext->SourceDistanceModel = AL_FALSE;
|
||||
pContext->DopplerFactor = 1.0f;
|
||||
pContext->DopplerVelocity = 1.0f;
|
||||
pContext->flSpeedOfSound = SPEEDOFSOUNDMETRESPERSEC;
|
||||
|
@ -589,7 +589,8 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource,
|
||||
RoomRolloff[i] += ALSource->Send[i].Slot->effect.Reverb.RoomRolloffFactor;
|
||||
}
|
||||
|
||||
switch(ALSource->DistanceModel)
|
||||
switch(ALContext->SourceDistanceModel ? ALSource->DistanceModel :
|
||||
ALContext->DistanceModel)
|
||||
{
|
||||
case AL_INVERSE_DISTANCE_CLAMPED:
|
||||
Distance=__max(Distance,MinDist);
|
||||
|
@ -310,6 +310,7 @@ struct ALCcontext_struct
|
||||
ALboolean InUse;
|
||||
|
||||
ALenum DistanceModel;
|
||||
ALboolean SourceDistanceModel;
|
||||
|
||||
ALfloat DopplerFactor;
|
||||
ALfloat DopplerVelocity;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "alThunk.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
|
||||
static ALvoid InitSourceParams(ALCcontext *Context, ALsource *pSource);
|
||||
static ALvoid InitSourceParams(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);
|
||||
@ -74,7 +74,7 @@ ALAPI ALvoid ALAPIENTRY alGenSources(ALsizei n,ALuint *sources)
|
||||
sources[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->source = sources[i];
|
||||
|
||||
InitSourceParams(Context, *list);
|
||||
InitSourceParams(*list);
|
||||
Context->SourceCount++;
|
||||
i++;
|
||||
|
||||
@ -697,7 +697,8 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
|
||||
lValue == AL_EXPONENT_DISTANCE_CLAMPED)
|
||||
{
|
||||
pSource->DistanceModel = lValue;
|
||||
pSource->NeedsUpdate = AL_TRUE;
|
||||
if(pContext->SourceDistanceModel)
|
||||
pSource->NeedsUpdate = AL_TRUE;
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
@ -1781,7 +1782,7 @@ ALAPI ALvoid ALAPIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint
|
||||
}
|
||||
|
||||
|
||||
static ALvoid InitSourceParams(ALCcontext *Context, ALsource *pSource)
|
||||
static ALvoid InitSourceParams(ALsource *pSource)
|
||||
{
|
||||
pSource->flInnerAngle = 360.0f;
|
||||
pSource->flOuterAngle = 360.0f;
|
||||
@ -1812,7 +1813,7 @@ static ALvoid InitSourceParams(ALCcontext *Context, ALsource *pSource)
|
||||
pSource->RoomRolloffFactor = 0.0f;
|
||||
pSource->DopplerFactor = 1.0f;
|
||||
|
||||
pSource->DistanceModel = Context->DistanceModel;
|
||||
pSource->DistanceModel = AL_INVERSE_DISTANCE_CLAMPED;
|
||||
|
||||
pSource->state = AL_INITIAL;
|
||||
pSource->lSourceType = AL_UNDETERMINED;
|
||||
|
@ -44,34 +44,66 @@ static const ALchar alErrOutOfMemory[] = "Out of Memory";
|
||||
ALAPI ALvoid ALAPIENTRY alEnable(ALenum capability)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALboolean updateSources = AL_FALSE;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
Context->SourceDistanceModel = AL_TRUE;
|
||||
updateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
if(updateSources)
|
||||
{
|
||||
ALsource *source = Context->Source;
|
||||
while(source)
|
||||
{
|
||||
source->NeedsUpdate = AL_TRUE;
|
||||
source = source->next;
|
||||
}
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alDisable(ALenum capability)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALboolean updateSources = AL_FALSE;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
Context->SourceDistanceModel = AL_FALSE;
|
||||
updateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
if(updateSources)
|
||||
{
|
||||
ALsource *source = Context->Source;
|
||||
while(source)
|
||||
{
|
||||
source->NeedsUpdate = AL_TRUE;
|
||||
source = source->next;
|
||||
}
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
@ -85,6 +117,10 @@ ALAPI ALboolean ALAPIENTRY alIsEnabled(ALenum capability)
|
||||
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
value = Context->SourceDistanceModel;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@ -588,7 +624,7 @@ ALAPI ALvoid ALAPIENTRY alSpeedOfSound(ALfloat flSpeedOfSound)
|
||||
ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsource *Source;
|
||||
ALboolean updateSources = AL_FALSE;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
@ -603,11 +639,7 @@ 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;
|
||||
Source->NeedsUpdate = AL_TRUE;
|
||||
}
|
||||
updateSources = !Context->SourceDistanceModel;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -615,5 +647,15 @@ ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value)
|
||||
break;
|
||||
}
|
||||
|
||||
if(updateSources)
|
||||
{
|
||||
ALsource *source = Context->Source;
|
||||
while(source)
|
||||
{
|
||||
source->NeedsUpdate = AL_TRUE;
|
||||
source = source->next;
|
||||
}
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
@ -150,6 +150,11 @@ typedef ALCboolean (ALC_APIENTRY*PFNALCMAKECURRENTPROC)(ALCcontext *context);
|
||||
typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void);
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_source_distance_model
|
||||
#define AL_EXT_source_distance_model 1
|
||||
#define AL_SOURCE_DISTANCE_MODEL 0x200
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user