From f33993dcb5f1406ceaaa8527d0cb59bda297de5c Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Tue, 9 Feb 2016 22:32:01 -0500 Subject: [PATCH 1/2] - 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. --- src/CMakeLists.txt | 14 ++------------ src/sound/oalload.h | 6 +++++- src/sound/oalsound.cpp | 21 ++++++++++++++++----- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d20ddf7c..a8e43bcf3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() diff --git a/src/sound/oalload.h b/src/sound/oalload.h index 7d4e62287..986131b2c 100644 --- a/src/sound/oalload.h +++ b/src/sound/oalload.h @@ -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" diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index a5ec97f97..6030c9142 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -36,6 +36,8 @@ #define WIN32_LEAN_AND_MEAN #include #define USE_WINDOWS_DWORD +#else +#include #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; From 65b70dedaa482264b04c1516493b377d40b91d06 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Tue, 9 Feb 2016 23:33:31 -0500 Subject: [PATCH 2/2] - Fixed: Heretic powered firemace balls didn't seek their target. --- src/g_heretic/a_hereticweaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 636b25a25..619fe7b5a 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -662,7 +662,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) } else { // Seek - self->angle = self->AngleTo(target); + angle = self->AngleTo(target); newAngle = true; } }