mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Use OpenAL by default
This commit is contained in:
parent
694167d352
commit
13911b051a
9 changed files with 44 additions and 24 deletions
|
@ -105,10 +105,10 @@ INSTALL(TARGETS omohaaded DESTINATION "./")
|
||||||
|
|
||||||
if (NOT BUILD_NO_CLIENT)
|
if (NOT BUILD_NO_CLIENT)
|
||||||
## Client app
|
## Client app
|
||||||
|
|
||||||
|
add_subdirectory("code/client")
|
||||||
add_subdirectory("code/renderer")
|
add_subdirectory("code/renderer")
|
||||||
add_subdirectory("code/sdl")
|
add_subdirectory("code/sdl")
|
||||||
add_subdirectory("code/client")
|
|
||||||
|
|
||||||
#include("code/renderergl2/glsl/shaders.cmake")
|
#include("code/renderergl2/glsl/shaders.cmake")
|
||||||
#file(GLOB_RECURSE SOURCES_RENDERER "code/sdl/*.c" "code/renderercommon/*.c" "code/renderergl2/*.c" "code/renderergl2/*.cpp")
|
#file(GLOB_RECURSE SOURCES_RENDERER "code/sdl/*.c" "code/renderercommon/*.c" "code/renderergl2/*.c" "code/renderergl2/*.cpp")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(omohclient)
|
project(omohclient)
|
||||||
|
|
||||||
|
option(NO_OPENAL "Use older sound-system" FALSE)
|
||||||
|
|
||||||
add_subdirectory("../cgame" "./cgame")
|
add_subdirectory("../cgame" "./cgame")
|
||||||
|
|
||||||
file(GLOB SOURCES_CLIENT "./*.c*")
|
file(GLOB SOURCES_CLIENT "./*.c*")
|
||||||
|
@ -18,11 +20,12 @@ target_link_libraries(omohclient INTERFACE gcd)
|
||||||
# Sound stuff
|
# Sound stuff
|
||||||
target_compile_definitions(omohclient INTERFACE USE_CODEC_MP3)
|
target_compile_definitions(omohclient INTERFACE USE_CODEC_MP3)
|
||||||
|
|
||||||
if (USE_SOUND_NEW)
|
if (NOT NO_OPENAL)
|
||||||
# Try to use OpenAL
|
# Use OpenAL
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
|
|
||||||
if (OPENAL_FOUND)
|
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)
|
if (MSVC)
|
||||||
target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL)
|
target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL)
|
||||||
else()
|
else()
|
||||||
|
@ -35,6 +38,13 @@ if (USE_SOUND_NEW)
|
||||||
file(GLOB SOURCES_CLIENT_SND "./snd_*_new.c*" "./snd_codec*.c*")
|
file(GLOB SOURCES_CLIENT_SND "./snd_*_new.c*" "./snd_codec*.c*")
|
||||||
list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND})
|
list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND})
|
||||||
else()
|
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$")
|
list(FILTER SOURCES_CLIENT EXCLUDE REGEX "./snd_([a-zA-Z0-9_]+)\.cpp$")
|
||||||
file(GLOB_RECURSE SOURCES_CLIENT_SND "./new/*.c*")
|
file(GLOB_RECURSE SOURCES_CLIENT_SND "./new/*.c*")
|
||||||
list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND})
|
list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND})
|
||||||
|
|
|
@ -769,7 +769,7 @@ void CL_ShutdownAll(qboolean shutdownRef) {
|
||||||
CL_cURL_Shutdown();
|
CL_cURL_Shutdown();
|
||||||
#endif
|
#endif
|
||||||
// clear sounds
|
// clear sounds
|
||||||
#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW
|
#if defined(NO_MODERN_DMA) && NO_MODERN_DMA
|
||||||
S_DisableSounds();
|
S_DisableSounds();
|
||||||
#endif
|
#endif
|
||||||
// shutdown CGame
|
// shutdown CGame
|
||||||
|
@ -1560,7 +1560,7 @@ void CL_Vid_Restart_f( void ) {
|
||||||
|
|
||||||
CL_StartHunkUsers(qfalse);
|
CL_StartHunkUsers(qfalse);
|
||||||
|
|
||||||
#if defined(USE_SOUND_NEW) && USE_SOUND_NEW
|
#if !defined(NO_MODERN_DMA) || !NO_MODERN_DMA
|
||||||
s_bSoundPaused = true;
|
s_bSoundPaused = true;
|
||||||
S_LoadData(&save);
|
S_LoadData(&save);
|
||||||
#else
|
#else
|
||||||
|
@ -1597,7 +1597,7 @@ handles will be invalid
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void CL_Snd_Restart_f( void ) {
|
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_Shutdown();
|
||||||
S_Init();
|
S_Init();
|
||||||
CL_Vid_Restart_f();
|
CL_Vid_Restart_f();
|
||||||
|
@ -3492,7 +3492,7 @@ void CL_Init( void ) {
|
||||||
|
|
||||||
Cvar_Set( "cl_running", "1" );
|
Cvar_Set( "cl_running", "1" );
|
||||||
|
|
||||||
#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW
|
#if defined(NO_MODERN_DMA) && NO_MODERN_DMA
|
||||||
S_Init2();
|
S_Init2();
|
||||||
#else
|
#else
|
||||||
S_Init(qtrue);
|
S_Init(qtrue);
|
||||||
|
@ -3537,7 +3537,7 @@ void CL_Shutdown(const char* finalmsg, qboolean disconnect, qboolean quit) {
|
||||||
if(disconnect)
|
if(disconnect)
|
||||||
CL_Disconnect();
|
CL_Disconnect();
|
||||||
|
|
||||||
#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW
|
#if defined(NO_MODERN_DMA) && NO_MODERN_DMA
|
||||||
S_Shutdown();
|
S_Shutdown();
|
||||||
#else
|
#else
|
||||||
S_Shutdown(qtrue);
|
S_Shutdown(qtrue);
|
||||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "../snd_local.h"
|
#include "../snd_local.h"
|
||||||
#include "../client.h"
|
#include "../client.h"
|
||||||
|
|
||||||
#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW
|
#if defined(NO_MODERN_DMA) && NO_MODERN_DMA
|
||||||
|
|
||||||
qboolean s_bSoundPaused = qfalse;
|
qboolean s_bSoundPaused = qfalse;
|
||||||
|
|
||||||
|
|
|
@ -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()
|
void load_sfx_info()
|
||||||
{
|
{
|
||||||
|
@ -95,5 +93,3 @@ void load_sfx_info()
|
||||||
|
|
||||||
sfx_infos[0].name[0] = 0;
|
sfx_infos[0].name[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "../qcommon/qcommon.h"
|
#include "../qcommon/qcommon.h"
|
||||||
#include "snd_public.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
|
#define PAINTBUFFER_SIZE 4096 // this is in samples
|
||||||
|
|
||||||
|
|
|
@ -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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(omohsdl)
|
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})
|
add_library(omohsdl STATIC ${SOURCES_SDL})
|
||||||
target_compile_features(omohsdl PUBLIC c_variadic_macros)
|
target_compile_features(omohsdl PUBLIC c_variadic_macros)
|
||||||
target_link_libraries(omohsdl PRIVATE qcommon qcommon_standalone)
|
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")
|
if(${CMAKE_VERSION} VERSION_GREATER "3.11")
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
|
|
|
@ -5,19 +5,21 @@ OpenMoHAA supports any architecture, thanks to the CMake build system and cross-
|
||||||
The following tools are required for all platforms:
|
The following tools are required for all platforms:
|
||||||
- CMake >= 3.5
|
- CMake >= 3.5
|
||||||
- Flex (>= 2.6.4) and Bison (>= 3.5.1)
|
- 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.
|
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.
|
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
|
## Compiling for Linux
|
||||||
|
|
||||||
These are the tools required on Linux :
|
These are the tools required on Linux :
|
||||||
- Clang >= 3.3 or GCC >= 4.8.5
|
- Clang >= 3.3 or GCC >= 4.8.5
|
||||||
- libsdl2-dev
|
- 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.
|
**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:
|
1 line install command with clang:
|
||||||
```sh
|
```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:
|
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.
|
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
|
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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue