Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f2ff77e
Global replace SDL2->SDL3
Lgt2x Dec 27, 2024
03e0b0f
SDL3: Functions that previously returned a negative error code now re…
Lgt2x Dec 27, 2024
780b88f
SDL3: run rename_symbols.py script from migration guide
Lgt2x Dec 27, 2024
3a1878c
SDL3: run rename_headers.py script from migration guide
Lgt2x Dec 27, 2024
fb796fe
SDL3: run rename_macros.py script from migration guide
Lgt2x Dec 27, 2024
867e800
Use new SDL3 Joystick functions
Lgt2x Dec 27, 2024
b642ef5
Rename SDL_FLT_EPSILON
Lgt2x Dec 27, 2024
44a6759
SDL3: use new audio API
Lgt2x Dec 27, 2024
6777ff1
SDL3: update input methods and structs
Lgt2x Dec 27, 2024
9306784
SDL3: Remove Gamma Ramp usage
Lgt2x Dec 27, 2024
2f87195
Fix event filter callbacks, and MouseMode callback
Lgt2x Dec 27, 2024
656d81d
SDL3: Update openGL/Window functions
Lgt2x Dec 27, 2024
cb379d7
Define SDL_FUNCTION_POINTER_IS_VOID_POINTER
Lgt2x Dec 27, 2024
0cb34f5
Remove relative import
Lgt2x Dec 27, 2024
88cd42f
Initialize SDL3 v3.1.6 as git submodule
Lgt2x Dec 29, 2024
5abb24d
Link SDL3 target & include directories properly, use SDL as a 3rd party
Lgt2x Dec 29, 2024
eca73af
Fix SDL3 usage & installation in docs and build files
Lgt2x Dec 29, 2024
e2d398f
VCPKG: do not use bundled plog and SDL
Lgt2x Dec 29, 2024
d3c4c12
include directX for windows anyway
Lgt2x Jan 1, 2025
8849a11
Third-party: remove submodules, only use find_package
Lgt2x Jan 2, 2025
284ed27
SDL Event filters: always return bool
Lgt2x Feb 14, 2025
25d4945
Fix fullscreen window initialization
Lgt2x Feb 14, 2025
7025224
Update VCPKG versions, create overlay for dbus for cross compilation
Lgt2x Feb 14, 2025
39ce5ea
Add missing SDL_free on structs allocated by SDL3
Lgt2x Feb 14, 2025
6f286e2
convert boolean switch to if/else logic
Lgt2x Feb 14, 2025
f71236e
Scale window using SDL_GetDisplayContentScale
Lgt2x Feb 16, 2025
34cc979
Fix mouse grab behavior
Lgt2x Feb 16, 2025
3be0be5
Gamma correction: do it in GLSL directly
Lgt2x Feb 17, 2025
7fc4626
Enable gamma correction setting on POSIX
Lgt2x Feb 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- runner: ubuntu-latest
preset: linux-cross-arm64
cc: gcc
cxx: g++++
cxx: g++
name: Linux-cross-arm64
build_type:
- Debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Generate git hash and tarball
run: |
sudo apt update
sudo apt install -y ninja-build cmake g++ libsdl2-dev zlib1g-dev
sudo apt install -y ninja-build cmake g++ zlib1g-dev
cmake --preset linux
cmake --build --preset linux -t get_git_hash
cmake --build --preset linux -t package_source
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

16 changes: 12 additions & 4 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
# Building Descent 3 Open Source

## Dependencies
The build process uses [**CMake**](https://cmake.org/) and, by default, [**Ninja**](https://ninja-build.org/). You must install these; the project cannot locate them for you. The source code depends on [**SDL2**](https://github.com/libsdl-org/SDL/tree/SDL2) and [**zlib**](https://github.com/madler/zlib). You can supply these dependencies yourself via your system's library management tools, or the build system can locate the dependencies for you using [vcpkg](https://github.com/microsoft/vcpkg), a cross-platform dependency-management system developed by Microsoft. The official builds source their dependencies from vcpkg.
The build process uses [**CMake**](https://cmake.org/) and, by default, [**Ninja**](https://ninja-build.org/). You must install these; the project cannot locate them for you. The source code also depends on third-party libraries that are not provided as part of the repository:
- [**SDL3**](https://wiki.libsdl.org/SDL3/FrontPage) which is used as the base to handle video, audio and input.
- [**cpp-httplib**](https://github.com/yhirose/cpp-httplib) as a HTTP client to download levels.
- [**glm**](https://github.com/g-truc/glm) providing useful additions to OpenGL.
- [**plog**](https://github.com/SergiusTheBest/plog) for logging
- [**zlib**](https://www.zlib.net/) as a compression utility
- [**gtest**](https://github.com/google/googletest) (optional) for testing.

You can supply these dependencies yourself via your system's library management tools, or the build system can locate the dependencies for you using [vcpkg](https://github.com/microsoft/vcpkg), a cross-platform dependency-management system developed by Microsoft. The official builds source their dependencies from vcpkg.

## Installing and using vcpkg
* When building for Windows, vcpkg is already installed and configured when using any of the Visual Studio command prompts (either actual Command Prompt, or PowerShell).
Expand Down Expand Up @@ -132,11 +140,11 @@ Once CMake finishes, the built files will be put in `builds/mac/build/Debug` or
* If you would like to manage the code dependencies yourself:
* APT users
```sh
sudo apt install -y --no-install-recommends libsdl2-dev zlib1g-dev libcpp-httplib-dev libgtest-dev libglm-dev
sudo apt install -y --no-install-recommends libsdl3-dev zlib1g-dev libcpp-httplib-dev libgtest-dev libglm-dev
```
* DNF users
```sh
sudo dnf install -y SDL2-devel zlib-devel cpp-httplib-devel gtest glm-devel
sudo dnf install -y SDL3-devel zlib-devel cpp-httplib-devel gtest glm-devel
```

3. **Clone the Descent3 source code.**
Expand Down Expand Up @@ -195,5 +203,5 @@ cmake --preset linux -DENABLE_LOGGER=ON
| `ENABLE_MEM_RTL` | Enable Real-time library memory management functions (disable to verbose memory allocations). | `ON` |
| `FORCE_COLORED_OUTPUT` | Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja). | `OFF` |
| `FORCE_PORTABLE_INSTALL` | Install all files into local directory defined by `CMAKE_INSTALL_PREFIX`. | `ON` |
| `USE_EXTERNAL_PLOG` | Use system plog library. | `OFF` |
| `OFF` |
| `USE_VCPKG` | Explicitly control whether or not to use vcpkg for dependency resolution. `ON` requires the environment variable `VCPKG_ROOT` to be set. | Determined by the existence of `VCPKG_ROOT` in the environment: If it exists, vcpkg is used. |
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ endif()
set(USE_VCPKG "DEFAULT" CACHE STRING "Use vcpkg for dependency management. DEFAULT defers to existence of $VCPKG_ROOT environment variable.")
set_property(CACHE USE_VCPKG PROPERTY STRINGS "DEFAULT" "ON" "OFF")

if(USE_VCPKG)
if(NOT USE_VCPKG STREQUAL "OFF")
if(DEFINED ENV{VCPKG_ROOT})

if (CMAKE_TOOLCHAIN_FILE)
cmake_path(ABSOLUTE_PATH CMAKE_TOOLCHAIN_FILE NORMALIZE OUTPUT_VARIABLE VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
endif()
Expand Down Expand Up @@ -42,7 +43,6 @@ option(ENABLE_MEM_RTL "Enable Real-time library memory management functions (dis
option(FATAL_GL_ERRORS "Check OpenGL calls and raise exceptions on errors." OFF)
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja)." OFF)
option(FORCE_PORTABLE_INSTALL "Install all files into local directory defined by CMAKE_INSTALL_PREFIX" ON)
option(USE_EXTERNAL_PLOG "Use system plog library instead bundled" OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(BUILD_EDITOR "Build internal editor" OFF)
endif()
Expand Down Expand Up @@ -159,23 +159,18 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
add_compile_options("-Wno-multichar;-Wall")
endif()

find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
find_package(glm REQUIRED)
find_package(httplib REQUIRED)
find_package(SDL2 REQUIRED)
# Some versions of the SDL2 find_package set SDL2_INCLUDE_DIR and some set a plural SDL2_INCLUDE_DIRS. Check both.
message("SDL2 Include Dir is ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS}")
if(USE_EXTERNAL_PLOG)
find_package(plog REQUIRED)
endif()
find_package(ZLIB REQUIRED)
find_package(plog REQUIRED)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
message("Building for Linux")
add_compile_definitions(POSIX __LINUX__ _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-linux.hog\")
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message("Building for MAC OSX")
add_compile_definitions(POSIX MACOSX=1 _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-osx.hog\")
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows.h defines to avoid as many issues as possible.
add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX NODRAWTEXT NOBITMAP NOMCX NOSERVICE PRIMARY_HOG=\"d3-win.hog\"
Expand All @@ -191,8 +186,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")

add_compile_definitions(WIN32 _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE)

set(PLATFORM_INCLUDES "lib/win/DirectX" "lib/win")

set(CMAKE_FIND_LIBRARY_PREFIXES "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")

Expand Down Expand Up @@ -221,8 +214,6 @@ endif()
add_compile_definitions($<$<CONFIG:Release>:RELEASE>)
add_compile_definitions($<$<CONFIG:Debug>:_DEBUG>)

find_package(ZLIB REQUIRED)

if(ENABLE_LOGGER)
message("Enabling Logging")
add_compile_definitions(LOGGER)
Expand All @@ -240,7 +231,10 @@ include_directories(
"lib" # TODO: Remove after untying all modules
"linux" # -*-
"Descent3"
${PLATFORM_INCLUDES}
$<$<PLATFORM_ID:Windows>:
"lib/win/DirectX"
"lib/win"
>
)

add_subdirectory(third_party)
Expand Down
4 changes: 2 additions & 2 deletions Descent3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ file(GLOB_RECURSE INCS "../lib/*.h")

add_executable(Descent3 WIN32 MACOSX_BUNDLE ${D3Icon} ${HEADERS} ${CPPS} ${INCS} ${MANIFEST} ${RC_FILE})
target_link_libraries(Descent3 PRIVATE
SDL2::SDL2
SDL3::SDL3
2dlib
AudioEncode
bitmap
Expand Down Expand Up @@ -343,7 +343,7 @@ target_link_libraries(Descent3 PRIVATE
unzip
vecmat
${PLATFORM_LIBS})
target_include_directories(Descent3 PRIVATE ${PROJECT_BINARY_DIR}/lib)
target_include_directories(Descent3 PRIVATE ${PROJECT_BINARY_DIR}/lib ${SDL3_INCLUDE_DIRS})
target_link_options(Descent3 PRIVATE $<$<PLATFORM_ID:Windows>:/DEBUG:FULL>)
set_target_properties(Descent3 PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build")
add_dependencies(Descent3
Expand Down
6 changes: 2 additions & 4 deletions Descent3/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,10 @@ struct video_menu {

sheet->NewGroup(TXT_MONITOR, 0, 180);
vsync = sheet->AddLongCheckBox(TXT_CFG_VSYNCENABLED, (Render_preferred_state.vsync_on != 0));
#if !defined(POSIX)

sheet->AddText("");
sheet->AddLongButton(TXT_AUTO_GAMMA, IDV_AUTOGAMMA);
#endif

return sheet;
};

Expand Down Expand Up @@ -736,13 +736,11 @@ struct video_menu {

// process
void process(int res) {
#if !defined(POSIX)
switch (res) {
case IDV_AUTOGAMMA:
config_gamma();
break;
}
#endif
};
};

Expand Down
2 changes: 1 addition & 1 deletion Descent3/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
*
* 169 4/16/99 11:56a Matt
* Changed directplay code to be "ifdef _WIN32" instead of "ifndef
* __LINUX__" so it will work on the Mac.
* SDL_PLATFORM_LINUX" so it will work on the Mac.
*
* 168 4/15/99 1:40a Jeff
* changes for linux compile
Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
*
* 61 4/16/99 11:56a Matt
* Changed directplay code to be "ifdef _WIN32" instead of "ifndef
* __LINUX__" so it will work on the Mac.
* SDL_PLATFORM_LINUX" so it will work on the Mac.
*
* 60 4/15/99 1:41a Jeff
* changes for linux compile
Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi_dll_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
*
* 61 4/16/99 11:56a Matt
* Changed directplay code to be "ifdef _WIN32" instead of "ifndef
* __LINUX__" so it will work on the Mac.
* SDL_PLATFORM_LINUX" so it will work on the Mac.
*
* 60 4/16/99 12:15a Jeff
* linux wants stdcall modifiers before parens, unlike windows
Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
*
* 82 4/16/99 11:56a Matt
* Changed directplay code to be "ifdef _WIN32" instead of "ifndef
* __LINUX__" so it will work on the Mac.
* SDL_PLATFORM_LINUX" so it will work on the Mac.
*
* 81 4/15/99 3:36p Kevin
* Added mouselook UI stuff to the multiplayer options menu
Expand Down
33 changes: 16 additions & 17 deletions Descent3/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <csignal>
#endif

#include <SDL.h>
#include <SDL3/SDL.h>

#include "appdatabase.h"
#include "application.h"
Expand Down Expand Up @@ -175,27 +175,27 @@ class oeD3LnxDatabase final : public oeLnxAppDatabase {
}
};

int sdlKeyFilter(const SDL_Event *event);
int sdlMouseButtonUpFilter(const SDL_Event *event);
int sdlMouseButtonDownFilter(const SDL_Event *event);
int sdlMouseWheelFilter(const SDL_Event *event);
int sdlMouseMotionFilter(const SDL_Event *event);
bool sdlKeyFilter(const SDL_Event *event);
bool sdlMouseButtonUpFilter(const SDL_Event *event);
bool sdlMouseButtonDownFilter(const SDL_Event *event);
bool sdlMouseWheelFilter(const SDL_Event *event);
bool sdlMouseMotionFilter(const SDL_Event *event);

int SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event) {
bool SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event) {
switch (event->type) {
case SDL_KEYUP:
case SDL_KEYDOWN:
case SDL_EVENT_KEY_UP:
case SDL_EVENT_KEY_DOWN:
return (sdlKeyFilter(event));
case SDL_JOYBALLMOTION:
case SDL_MOUSEMOTION:
case SDL_EVENT_JOYSTICK_BALL_MOTION:
case SDL_EVENT_MOUSE_MOTION:
return (sdlMouseMotionFilter(event));
case SDL_MOUSEBUTTONUP:
case SDL_EVENT_MOUSE_BUTTON_UP:
return (sdlMouseButtonUpFilter(event));
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTON_DOWN:
return (sdlMouseButtonDownFilter(event));
case SDL_MOUSEWHEEL:
case SDL_EVENT_MOUSE_WHEEL:
return (sdlMouseWheelFilter(event));
case SDL_QUIT:
case SDL_EVENT_QUIT:
SDL_Quit();
_exit(0);
break;
Expand Down Expand Up @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) {
#endif

int rc = SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO);
if (rc != 0) {
if (!rc) {
LOG_FATAL.printf("SDL: SDL_Init() failed: %d: %s!", rc, SDL_GetError());
return (0);
}
Expand Down Expand Up @@ -273,7 +273,6 @@ int main(int argc, char *argv[]) {
flags |= APPFLAG_NOMOUSECAPTURE;
ddio_MouseSetGrab(false);
}
SDL_SetRelativeMouseMode(ddio_MouseGetGrab() ? SDL_TRUE : SDL_FALSE);

if (!FindArg("-sharedmemory")) {
flags |= APPFLAG_NOSHAREDMEMORY;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/terrainrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@ int DrawTerrainTrianglesSoftware(int index, int bm_handle, int upper_left, int l
}
}
#endif
#endif//__LINUX__
#endif//SDL_PLATFORM_LINUX
*/
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion ddebug/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ target_include_directories(ddebug PUBLIC
${PROJECT_SOURCE_DIR}/ddebug
>
PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h
${SDL3_INCLUDE_DIRS}
)
target_link_libraries(ddebug PRIVATE
$<$<PLATFORM_ID:Windows>:
mem
misc
>
PUBLIC
SDL2::SDL2
SDL3::SDL3
logger
)
2 changes: 1 addition & 1 deletion ddebug/lnxdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/

#include <cstdio>
#include <SDL_assert.h>
#include <SDL3/SDL_assert.h>

#include "debug.h"

Expand Down
2 changes: 1 addition & 1 deletion ddebug/pserror.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
#ifndef PSERROR_H
#define PSERROR_H

#include <SDL_assert.h>
#include <SDL3/SDL_assert.h>

#include "debug.h"
#include "log.h"
Expand Down
3 changes: 2 additions & 1 deletion ddio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set(CPPS
)
add_library(ddio STATIC ${HEADERS} ${CPPS})
target_link_libraries(ddio PRIVATE
SDL2::SDL2
SDL3::SDL3
ddebug
logger
mem
Expand All @@ -37,6 +37,7 @@ target_include_directories(ddio PUBLIC
$<BUILD_INTERFACE:
${PROJECT_SOURCE_DIR}/ddio
>
${SDL3_INCLUDE_DIRS}
)

if(BUILD_TESTING)
Expand Down
Loading
Loading