diff --git a/CMakeLists.txt b/CMakeLists.txt index ac6ed6c8..5cdf0e0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,10 +105,10 @@ INSTALL(TARGETS omohaaded DESTINATION "./") if (NOT BUILD_NO_CLIENT) ## Client app - + + add_subdirectory("code/client") add_subdirectory("code/renderer") add_subdirectory("code/sdl") - add_subdirectory("code/client") #include("code/renderergl2/glsl/shaders.cmake") #file(GLOB_RECURSE SOURCES_RENDERER "code/sdl/*.c" "code/renderercommon/*.c" "code/renderergl2/*.c" "code/renderergl2/*.cpp") diff --git a/code/client/CMakeLists.txt b/code/client/CMakeLists.txt index e974e7af..ff7660c8 100644 --- a/code/client/CMakeLists.txt +++ b/code/client/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.5) project(omohclient) +option(NO_OPENAL "Use older sound-system" FALSE) + add_subdirectory("../cgame" "./cgame") file(GLOB SOURCES_CLIENT "./*.c*") @@ -18,11 +20,12 @@ target_link_libraries(omohclient INTERFACE gcd) # Sound stuff target_compile_definitions(omohclient INTERFACE USE_CODEC_MP3) -if (USE_SOUND_NEW) - # Try to use OpenAL +if (NOT NO_OPENAL) + # Use OpenAL find_package(OpenAL REQUIRED) + if (OPENAL_FOUND) - target_compile_definitions(omohclient INTERFACE USE_OPENAL=1 USE_SOUND_NEW=1) + target_compile_definitions(omohclient INTERFACE USE_OPENAL=1 NO_MODERN_DMA=0) if (MSVC) target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL) else() @@ -35,6 +38,13 @@ if (USE_SOUND_NEW) file(GLOB SOURCES_CLIENT_SND "./snd_*_new.c*" "./snd_codec*.c*") list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND}) else() + # + # Fallback to old DMA sound system + # + message(NOTICE "OpenAL was explicitly disabled - fallback to old SDL sound system") + target_compile_definitions(omohclient INTERFACE NO_MODERN_DMA=1) + set(NO_MODERN_DMA TRUE) + list(FILTER SOURCES_CLIENT EXCLUDE REGEX "./snd_([a-zA-Z0-9_]+)\.cpp$") file(GLOB_RECURSE SOURCES_CLIENT_SND "./new/*.c*") list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND}) diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 825ea52c..a2e61c3a 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -769,7 +769,7 @@ void CL_ShutdownAll(qboolean shutdownRef) { CL_cURL_Shutdown(); #endif // clear sounds -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_DisableSounds(); #endif // shutdown CGame @@ -1560,7 +1560,7 @@ void CL_Vid_Restart_f( void ) { CL_StartHunkUsers(qfalse); -#if defined(USE_SOUND_NEW) && USE_SOUND_NEW +#if !defined(NO_MODERN_DMA) || !NO_MODERN_DMA s_bSoundPaused = true; S_LoadData(&save); #else @@ -1597,7 +1597,7 @@ handles will be invalid ================= */ void CL_Snd_Restart_f( void ) { -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_Shutdown(); S_Init(); CL_Vid_Restart_f(); @@ -3492,7 +3492,7 @@ void CL_Init( void ) { Cvar_Set( "cl_running", "1" ); -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_Init2(); #else S_Init(qtrue); @@ -3537,7 +3537,7 @@ void CL_Shutdown(const char* finalmsg, qboolean disconnect, qboolean quit) { if(disconnect) CL_Disconnect(); -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_Shutdown(); #else S_Shutdown(qtrue); diff --git a/code/client/new/snd_main_new.cpp b/code/client/new/snd_main_new.cpp index 66fa6f1f..58deebe1 100644 --- a/code/client/new/snd_main_new.cpp +++ b/code/client/new/snd_main_new.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../snd_local.h" #include "../client.h" -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA qboolean s_bSoundPaused = qfalse; diff --git a/code/client/snd_info.cpp b/code/client/snd_info.cpp index 6cbdc02b..6fa56996 100644 --- a/code/client/snd_info.cpp +++ b/code/client/snd_info.cpp @@ -20,10 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#if USE_SOUND_NEW - -# include "snd_local.h" -# include "../qcommon/tiki.h" +#include "snd_local.h" +#include "../qcommon/tiki.h" void load_sfx_info() { @@ -95,5 +93,3 @@ void load_sfx_info() sfx_infos[0].name[0] = 0; } - -#endif diff --git a/code/client/snd_local.h b/code/client/snd_local.h index e0ec8609..04c6ba9f 100644 --- a/code/client/snd_local.h +++ b/code/client/snd_local.h @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/qcommon.h" #include "snd_public.h" -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA #define PAINTBUFFER_SIZE 4096 // this is in samples diff --git a/code/client/snd_public.h b/code/client/snd_public.h index f348cdc9..596e066f 100644 --- a/code/client/snd_public.h +++ b/code/client/snd_public.h @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA #ifdef __cplusplus extern "C" { diff --git a/code/sdl/CMakeLists.txt b/code/sdl/CMakeLists.txt index 27c9e804..db79ee2f 100644 --- a/code/sdl/CMakeLists.txt +++ b/code/sdl/CMakeLists.txt @@ -1,12 +1,23 @@ cmake_minimum_required(VERSION 3.5) project(omohsdl) -file(GLOB_RECURSE SOURCES_SDL "./*.c") +file(GLOB SOURCES_SDL +"./sdl_gamma.c" +"./sdl_glimp.c" +"./sdl_input.c" +) + +if (NO_MODERN_DMA) + list(APPEND SOURCES_SDL "./sdl_snd.c") +endif() add_library(omohsdl STATIC ${SOURCES_SDL}) target_compile_features(omohsdl PUBLIC c_variadic_macros) target_link_libraries(omohsdl PRIVATE qcommon qcommon_standalone) +if (NO_MODERN_DMA) + target_compile_definitions(omohsdl PRIVATE NO_MODERN_DMA=1) +endif() if(${CMAKE_VERSION} VERSION_GREATER "3.11") cmake_policy(SET CMP0074 NEW) diff --git a/docs/compiling.md b/docs/compiling.md index dd9c6f4f..393329bc 100644 --- a/docs/compiling.md +++ b/docs/compiling.md @@ -5,19 +5,21 @@ OpenMoHAA supports any architecture, thanks to the CMake build system and cross- The following tools are required for all platforms: - CMake >= 3.5 - Flex (>= 2.6.4) and Bison (>= 3.5.1) -- A C++11 compiler is also required. +- A C++11 compiler +- OpenAL SDK (can be found [here](https://github.com/kcat/openal-soft)) The installation directory can be set to the MOHAA directory. By default, the build will produce both the client and dedicated server versions. The client can be omitted from the build by appending `-DBUILD_NO_CLIENT=1` to the CMake command-line arguments. Using this parameter will result in only the server portion being built. -The experimental OpenAL-based sound system can be used by appending `-DUSE_SOUND_NEW=1` to the CMake command-line arguments. +OpenAL can be disabled by appending `-DNO_OPENAL=1` to the CMake command-line arguments. The old SDL-based sound system will be used instead, it lacks some features such as ambient sounds. ## Compiling for Linux These are the tools required on Linux : - Clang >= 3.3 or GCC >= 4.8.5 - libsdl2-dev +- libopenal-dev **clang-3.5** and **gcc-4.8.5** should work (tested on Ubuntu 16.04), but the latest version should be used. @@ -25,7 +27,7 @@ Ubuntu 20.04 is the minimum version required to fully compile the project succes 1 line install command with clang: ```sh -sudo apt-get install -y cmake ninja-build clang lld flex bison libsdl2-dev +sudo apt-get install -y cmake ninja-build clang lld flex bison libsdl2-dev libopenal-dev ``` Example with **CMake** and **ninja-build** installed: @@ -41,5 +43,6 @@ Other compilers can be specified by appending `-DCMAKE_C_COMPILER=/path/to/compi Visual Studio (2019 or 2022) is generally preferred. Flex and Bison can be downloaded from here: https://github.com/lexxmark/winflexbison/releases/tag/v2.5.25 +OpenAL can be downloaded from here: https://github.com/kcat/openal-soft/releases/tag/1.23.1 -Append `-DFLEX_EXECUTABLE=...\win_flex.exe -DBISON_EXECUTABLE=...\win_bison.exe` to the CMake command-line to use the package from the link above. +Append `-DFLEX_EXECUTABLE=...\win_flex.exe -DBISON_EXECUTABLE=...\win_bison.exe -DOPENAL_INCLUDE_DIR="path/to/oal/include" -DOPENAL_LIBRARY="path/to/oal"` to the CMake command-line to use the package from the link above.