mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-22 03:41:25 +00:00
Added option to control dynamic loading of OpenAL
Dynamic loading is enabled by default, set DYN_OPENAL to OFF to link with static or dynamic library # Conflicts: # src/sound/oalsound.cpp # src/sound/oalsound.h
This commit is contained in:
parent
243030046a
commit
5348a15b75
4 changed files with 36 additions and 21 deletions
|
@ -28,6 +28,7 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON )
|
option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON )
|
||||||
|
option( DYN_OPENAL "Dynamically load OpenAL" ON )
|
||||||
|
|
||||||
if( APPLE )
|
if( APPLE )
|
||||||
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
|
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
|
||||||
|
@ -226,13 +227,23 @@ endif()
|
||||||
|
|
||||||
|
|
||||||
if( NOT NO_OPENAL )
|
if( NOT NO_OPENAL )
|
||||||
find_package( OpenAL )
|
find_package( OpenAL )
|
||||||
mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
|
mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
|
||||||
if( OPENAL_INCLUDE_DIR )
|
if( OPENAL_INCLUDE_DIR )
|
||||||
include_directories( ${OPENAL_INCLUDE_DIR} )
|
include_directories( ${OPENAL_INCLUDE_DIR} )
|
||||||
else()
|
if( DYN_OPENAL )
|
||||||
|
add_definitions( -DDYN_OPENAL )
|
||||||
|
else()
|
||||||
|
mark_as_advanced(CLEAR OPENAL_LIBRARY)
|
||||||
|
if( OPENAL_LIBRARY )
|
||||||
|
set( ZDOOM_LIBS ${OPENAL_LIBRARY} ${ZDOOM_LIBS} )
|
||||||
|
else()
|
||||||
|
set( NO_OPENAL ON )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
set( NO_OPENAL ON )
|
set( NO_OPENAL ON )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( NOT NO_FMOD )
|
if( NOT NO_FMOD )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef OALDEF_H
|
#ifndef OALDEF_H
|
||||||
#define OALDEF_H
|
#define OALDEF_H
|
||||||
|
|
||||||
#ifndef NO_OPENAL
|
#if !defined NO_OPENAL && defined DYN_OPENAL
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
typedef void* FARPROC;
|
typedef void* FARPROC;
|
||||||
|
|
|
@ -83,6 +83,8 @@ bool IsOpenALPresent()
|
||||||
{
|
{
|
||||||
#ifdef NO_OPENAL
|
#ifdef NO_OPENAL
|
||||||
return false;
|
return false;
|
||||||
|
#elif !defined DYN_OPENAL
|
||||||
|
return true;
|
||||||
#else
|
#else
|
||||||
static bool cached_result = false;
|
static bool cached_result = false;
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
|
@ -425,10 +427,10 @@ public:
|
||||||
virtual bool IsEnded()
|
virtual bool IsEnded()
|
||||||
{
|
{
|
||||||
return !Playing.load();
|
return !Playing.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual FString GetStats()
|
virtual FString GetStats()
|
||||||
{
|
{
|
||||||
FString stats;
|
FString stats;
|
||||||
size_t pos, len;
|
size_t pos, len;
|
||||||
ALfloat volume;
|
ALfloat volume;
|
||||||
|
@ -1538,24 +1540,24 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||||
alSource3f(source, AL_POSITION, dir[0], dir[1], -dir[2]);
|
alSource3f(source, AL_POSITION, dir[0], dir[1], -dir[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FVector3 dir = pos;
|
FVector3 dir = pos;
|
||||||
if(AL.EXT_SOURCE_RADIUS)
|
if(AL.EXT_SOURCE_RADIUS)
|
||||||
alSourcef(source, AL_SOURCE_RADIUS, (chanflags&SNDF_AREA) ? AREA_SOUND_RADIUS : 0.f);
|
alSourcef(source, AL_SOURCE_RADIUS, (chanflags&SNDF_AREA) ? AREA_SOUND_RADIUS : 0.f);
|
||||||
else if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)
|
else if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)
|
||||||
{
|
{
|
||||||
dir -= listener->position;
|
dir -= listener->position;
|
||||||
|
|
||||||
float mindist = rolloff->MinDistance/distscale;
|
float mindist = rolloff->MinDistance/distscale;
|
||||||
FVector3 amb(0.f, !(dir.Y>=0.f) ? -mindist : mindist, 0.f);
|
FVector3 amb(0.f, !(dir.Y>=0.f) ? -mindist : mindist, 0.f);
|
||||||
float a = sqrtf(dist_sqr) / AREA_SOUND_RADIUS;
|
float a = sqrtf(dist_sqr) / AREA_SOUND_RADIUS;
|
||||||
dir = amb + (dir-amb)*a;
|
dir = amb + (dir-amb)*a;
|
||||||
|
|
||||||
dir += listener->position;
|
dir += listener->position;
|
||||||
}
|
}
|
||||||
if(dist_sqr < (0.0004f*0.0004f))
|
if(dist_sqr < (0.0004f*0.0004f))
|
||||||
{
|
{
|
||||||
|
@ -1566,8 +1568,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||||
alSource3f(source, AL_POSITION, dir[0], dir[1], -dir[2]);
|
alSource3f(source, AL_POSITION, dir[0], dir[1], -dir[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alSource3f(source, AL_VELOCITY, vel[0], vel[1], -vel[2]);
|
alSource3f(source, AL_VELOCITY, vel[0], vel[1], -vel[2]);
|
||||||
alSource3f(source, AL_DIRECTION, 0.f, 0.f, 0.f);
|
alSource3f(source, AL_DIRECTION, 0.f, 0.f, 0.f);
|
||||||
|
@ -1799,7 +1801,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh
|
||||||
{
|
{
|
||||||
float gain = GetRolloff(&chan->Rolloff, sqrtf(chan->DistanceSqr)*chan->DistanceScale);
|
float gain = GetRolloff(&chan->Rolloff, sqrtf(chan->DistanceSqr)*chan->DistanceScale);
|
||||||
dir.MakeResize((gain > 0.00001f) ? 1.f/gain : 100000.f);
|
dir.MakeResize((gain > 0.00001f) ? 1.f/gain : 100000.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!AL.EXT_SOURCE_RADIUS && areasound &&
|
else if(!AL.EXT_SOURCE_RADIUS && areasound &&
|
||||||
chan->DistanceSqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)
|
chan->DistanceSqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)
|
||||||
|
@ -1822,7 +1824,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||||
alSource3f(source, AL_POSITION, dir[0], dir[1], -dir[2]);
|
alSource3f(source, AL_POSITION, dir[0], dir[1], -dir[2]);
|
||||||
}
|
}
|
||||||
alSource3f(source, AL_VELOCITY, vel[0], vel[1], -vel[2]);
|
alSource3f(source, AL_VELOCITY, vel[0], vel[1], -vel[2]);
|
||||||
getALError();
|
getALError();
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
|
|
||||||
#ifndef NO_OPENAL
|
#ifndef NO_OPENAL
|
||||||
|
|
||||||
|
#ifdef DYN_OPENAL
|
||||||
#define AL_NO_PROTOTYPES
|
#define AL_NO_PROTOTYPES
|
||||||
|
#endif // DYN_OPENAL
|
||||||
|
|
||||||
#include "al.h"
|
#include "al.h"
|
||||||
#include "alc.h"
|
#include "alc.h"
|
||||||
|
|
Loading…
Reference in a new issue