mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
- Load OpenAL at runtime for all platforms because I can't think of a good reason not to handle them all the same right now.
This commit is contained in:
parent
3358181f18
commit
f33993dcb5
3 changed files with 23 additions and 18 deletions
|
@ -217,20 +217,10 @@ endif()
|
|||
if( NOT NO_OPENAL )
|
||||
find_package( OpenAL )
|
||||
mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
|
||||
if( NOT WIN32 )
|
||||
mark_as_advanced(CLEAR OPENAL_LIBRARY)
|
||||
endif()
|
||||
if( OPENAL_FOUND )
|
||||
if( OPENAL_INCLUDE_DIR )
|
||||
include_directories( ${OPENAL_INCLUDE_DIR} )
|
||||
if( NOT WIN32 )
|
||||
set( ZDOOM_LIBS ${OPENAL_LIBRARY} ${ZDOOM_LIBS} )
|
||||
endif()
|
||||
else()
|
||||
if ( NOT WIN32 )
|
||||
set( NO_OPENAL ON )
|
||||
else()
|
||||
include_directories( ${OPENAL_INCLUDE_DIR} )
|
||||
endif()
|
||||
set( NO_OPENAL ON )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#ifndef OALDEF_H
|
||||
#define OALDEF_H
|
||||
|
||||
#if defined _WIN32 && !defined NO_OPENAL
|
||||
#ifndef NO_OPENAL
|
||||
|
||||
#ifndef _WIN32
|
||||
typedef void* FARPROC;
|
||||
#endif
|
||||
|
||||
#define DEFINE_ENTRY(type, name) static type p_##name;
|
||||
#include "oaldef.h"
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#define USE_WINDOWS_DWORD
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include "except.h"
|
||||
|
@ -61,14 +63,23 @@ CVAR (Bool, snd_efx, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
|
||||
#ifdef _WIN32
|
||||
static HMODULE hmodOpenAL;
|
||||
#define OPENALLIB "openal32.dll"
|
||||
#else
|
||||
static void* hmodOpenAL;
|
||||
#ifdef __APPLE__
|
||||
#define OPENALLIB "OpenAL.framework/OpenAL"
|
||||
#else
|
||||
#define OPENALLIB "libopenal.so"
|
||||
#endif
|
||||
#define LoadLibrary(x) dlopen((x), RTLD_LAZY)
|
||||
#define GetProcAddress(a,b) dlsym((a),(b))
|
||||
#define FreeLibrary(x) dlclose((x))
|
||||
#endif
|
||||
|
||||
bool IsOpenALPresent()
|
||||
{
|
||||
#ifdef NO_OPENAL
|
||||
return false;
|
||||
#elif !defined _WIN32
|
||||
return true;
|
||||
#else
|
||||
static bool cached_result = false;
|
||||
static bool done = false;
|
||||
|
@ -78,10 +89,10 @@ bool IsOpenALPresent()
|
|||
done = true;
|
||||
if (hmodOpenAL == NULL)
|
||||
{
|
||||
hmodOpenAL = LoadLibrary(NicePath("$PROGDIR/openal32.dll"));
|
||||
hmodOpenAL = LoadLibrary(NicePath("$PROGDIR/" OPENALLIB));
|
||||
if (hmodOpenAL == NULL)
|
||||
{
|
||||
hmodOpenAL = LoadLibrary("openal32.dll");
|
||||
hmodOpenAL = LoadLibrary(OPENALLIB);
|
||||
if (hmodOpenAL == NULL)
|
||||
{
|
||||
return false;
|
||||
|
@ -90,7 +101,7 @@ bool IsOpenALPresent()
|
|||
for(int i = 0; oalfuncs[i].name != NULL; i++)
|
||||
{
|
||||
*oalfuncs[i].funcaddr = GetProcAddress(hmodOpenAL, oalfuncs[i].name);
|
||||
if (oalfuncs[i].funcaddr == NULL)
|
||||
if (*oalfuncs[i].funcaddr == NULL)
|
||||
{
|
||||
FreeLibrary(hmodOpenAL);
|
||||
hmodOpenAL = NULL;
|
||||
|
|
Loading…
Reference in a new issue