Skip to content

Commit

Permalink
Merge branch 'main' into ryan-sdl2-port
Browse files Browse the repository at this point in the history
  • Loading branch information
JeodC committed May 1, 2024
2 parents 815628b + ae03b6f commit 23af70e
Show file tree
Hide file tree
Showing 35 changed files with 163 additions and 48,496 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ jobs:
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
ninja-build cmake g++ libgtest-dev libsdl2-dev libncurses-dev zlib1g-dev
ninja-build cmake g++ libgtest-dev libsdl2-dev libncurses-dev zlib1g-dev libspdlog-dev
- name: Configure CMake
env:
Expand Down
3 changes: 3 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ brew "ninja"

# zlib
brew "zlib"

# spdlog
brew "spdlog"
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ project(Descent3
)

option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with ninja)." OFF)
option(LOGGER "Enable logging to the terminal" OFF)
option(ENABLE_LOGGER "Enable logging to the terminal" OFF)
option(BUILD_TESTING "Enable testing. Requires GTest." OFF)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(spdlog REQUIRED)

if(FORCE_COLORED_OUTPUT)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
set(CMAKE_COLOR_DIAGNOSTICS ON)
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
add_compile_options(-fdiagnostics-color=always)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options (-fcolor-diagnostics)
add_compile_options(-fcolor-diagnostics)
endif()
endif()
endif()
Expand Down Expand Up @@ -87,7 +90,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message("Building for MAC OSX")
add_compile_definitions(__LINUX__ LINUX _MAX_PATH=260 _MAX_FNAME=256 _REENRANT MACOSX=1 _USE_OGL_ACTIVE_TEXTURES)
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS} "/usr/X11/include") # !!! FIXME: why X11?
set(PLATFORM_INCLUDES "lib/linux" ${SDL_INCLUDE_DIR})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(APPEND CMAKE_LIBRARY_PATH "lib/win" "lib/win/directx")
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>>:/EHsc;/RTC1;/W3;/nologo;/c;/Zi;/TP;/errorReport:prompt>")
Expand Down Expand Up @@ -128,13 +131,14 @@ add_compile_definitions($<$<CONFIG:Debug>:_DEBUG>)

find_package(ZLIB REQUIRED)

if(LOGGER)
if(ENABLE_LOGGER)
message("Enabling Logging")
add_compile_definitions(LOGGER)
endif()

include_directories(
"cfile" # TODO: Remove after untying all modules
"ddebug" # -*-
"lib" # TODO: Remove after untying all modules
"Descent3"
${PLATFORM_INCLUDES}
Expand All @@ -148,6 +152,7 @@ add_subdirectory(bitmap)
add_subdirectory(cfile)
add_subdirectory(czip)
add_subdirectory(d3music)
add_subdirectory(ddebug)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_subdirectory(dd_grwin32)
Expand Down
2 changes: 1 addition & 1 deletion Descent3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ add_executable(Descent3
${HEADERS} ${CPPS} ${PLATFORM_CPPS} ${INCS}
)
target_link_libraries(Descent3
2dlib AudioEncode bitmap cfile czip d3music ddio_common libmve libacm
2dlib AudioEncode bitmap cfile czip d3music ddebug ddio_common libmve libacm
fix grtext manage mem misc model module movie stream_audio
music networking physics renderer rtperformance sndlib ui unzip vecmat md5
${PLATFORM_LIBS})
Expand Down
13 changes: 13 additions & 0 deletions Descent3/lnxmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#include "osiris_dll.h"
#include "loki_utils.h"

#include "log.h"

#if defined(MACOSX)
#include <SDL.h>
#endif
Expand Down Expand Up @@ -474,6 +476,15 @@ static void check_beta() {
int main(int argc, char *argv[]) {
__orig_pwd = getcwd(NULL, 0);

/* Setup the spdlog system */
InitLog();

#ifdef DEBUG
spdlog::set_level(spdlog::level::debug);
#else
spdlog::set_level(spdlog::level::info);
#endif

setbuf(stdout, NULL);
setbuf(stderr, NULL);

Expand Down Expand Up @@ -569,6 +580,8 @@ int main(int argc, char *argv[]) {
#endif
D3_MAJORVER, D3_MINORVER, D3_BUILD, D3_GIT_HASH);

SPDLOG_INFO(game_version_buffer);

game_version += 2; // skip those first newlines for loki_initialize.

register_d3_args();
Expand Down
1 change: 0 additions & 1 deletion Descent3/loki_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ void loki_initialize(int argc, char **argv, char *desc) {
// printf("base path: %s\n", basepath);
// printf("pref path: %s\n", prefpath);

printf("%s\n", desc);
} /* loki_initialize */

/* end of loki_utils.c ... */
3 changes: 3 additions & 0 deletions Descent3/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "init.h"
#include "dedicated_server.h"
#include "resource.h"
#include "log.h"

const char *English_strings[] = {"Descent 3 under Windows NT requires version 4.0 or greater of NT to run.",
"Descent 3 requires Windows 9x, NT 4.0 or greater to run.",
Expand Down Expand Up @@ -594,6 +595,8 @@ int PASCAL HandledWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine,
extern bool w32_mouseman_hack; // from winapp.cpp
extern bool joy_chpro_hack; // located in winjoy.cpp

InitLog();

strupr(szCmdLine);
GatherArgs(szCmdLine);

Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,31 @@ setx PATH=%VCPKG_ROOT%;%PATH%

Build Descent 3:
```sh
cmake --preset win -D LOGGER=[ON|OFF]
cmake --preset win -D ENABLE_LOGGER=[ON|OFF]
cmake --build --preset win --config [Debug|Release]
```

#### Building - MacOS
```sh
brew bundle install
cmake --preset mac -D LOGGER=[ON|OFF]
cmake --preset mac -D ENABLE_LOGGER=[ON|OFF]
cmake --build --preset mac --config [Debug|Release]
```

#### Building - Linux
#### Building - Linux (Ubuntu)
```sh
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev libxext6:i386 zlib1g-dev
sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev libxext6:i386 zlib1g-dev spdlog-dev
cmake --preset linux -D LOGGER=[ON|OFF]
cmake --build --preset linux --config [Debug|Release]
```

#### Building - Linux (Fedora)
```sh
sudo dnf update --refresh
sudo dnf install -y ninja-build cmake gcc-c++ SDL-devel SDL_image-devel ncurses-devel libXext.x86_64 zlib-devel spdlog-devel
sudo dnf install -y libXext.i686
cmake --preset linux -D LOGGER=[ON|OFF]
cmake --build --preset linux --config [Debug|Release]
```
Expand Down
1 change: 1 addition & 0 deletions bitmap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ set(CPPS
add_library(bitmap STATIC ${HEADERS} ${CPPS})
target_link_libraries(bitmap PRIVATE
cfile
ddebug
)
19 changes: 19 additions & 0 deletions ddebug/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(CPPS
$<$<PLATFORM_ID:Darwin,Linux>:
lnxdebug.cpp
lnxmono.cpp
>
$<$<PLATFORM_ID:Windows>:
windebug.cpp
winmono.cpp
>
)

add_library(ddebug STATIC ${CPPS})
add_dependencies(ddebug get_git_hash)
target_include_directories(ddebug PUBLIC
$<BUILD_INTERFACE:
${PROJECT_SOURCE_DIR}/ddebug
>
PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions ddio_lnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ set(CPPS
lnxkey_sdl.cpp)

add_library(ddio_lnx STATIC ${HEADERS} ${CPPS})
target_link_libraries(ddio_lnx
ddebug
)
1 change: 0 additions & 1 deletion legacy/renderer/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#elif defined(__LINUX__)
#include "linux/linux_fix.h"
#include "lnxscreenmode.h"
#include <X11/Xatom.h>
#else
#endif

Expand Down
99 changes: 0 additions & 99 deletions lib/linux/dyna_oxlib.h

This file was deleted.

0 comments on commit 23af70e

Please sign in to comment.