Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0ef140d
HogMaker as external project
Lgt2x Jul 21, 2024
7d62278
Fix printf security hole
tophyr Dec 30, 2024
1d18b25
Add top-level Android compile definitions, based on Linux
tophyr Jun 21, 2024
4a8730a
Generate a d3-android-fullhog
tophyr Jun 22, 2024
2e38c6d
Produce a module instead of an executable for Android
tophyr Jun 23, 2024
23d5080
Support both GLES 3.0 and GL 3.2
tophyr Aug 12, 2024
0b82fff
Add Android support
tophyr Jun 24, 2024
28983f9
Extract gamedata knowledge into dedicated common methods
tophyr Jan 1, 2025
f992e0a
Add instructions to Gamedata Upload screen
tophyr Jan 2, 2025
6f02671
Lock game to landscape mode
tophyr Jan 6, 2025
19b5863
Gradle upgrade
tophyr Jan 13, 2026
be72886
Merge branch 'main' into android
tophyr Jan 13, 2026
bbdc6d8
Revert "HogMaker as external project"
tophyr Jan 13, 2026
9816875
Build HogMaker explicitly when cross-compiling
tophyr Jan 14, 2026
a251363
Fix android build to work
tophyr Jan 14, 2026
a7532a4
Update Android code to SDL 3.2.6
tophyr Jan 14, 2026
55137c9
use SDL_main
tophyr Jan 14, 2026
31ec3a4
Ignore base directories that happen to be the root of the drive
tophyr Jan 15, 2026
962bc38
Use SDL_PollEvent instead of Event Filters
tophyr Jan 21, 2026
17beb9c
Don't emulate mouse via touch
tophyr Jan 21, 2026
3f5e7bb
Merge branch 'main' into android
tophyr Jan 21, 2026
cfd35f1
Merge remote-tracking branch 'origin/pr/poll-sdl-events' into android
tophyr Jan 21, 2026
484e52d
Add ability to track touches for input
tophyr Jan 21, 2026
62e939b
End a movie if the screen is touched
tophyr Jan 21, 2026
8218908
deduplicate ui code
tophyr Jan 21, 2026
4cbca11
clean up unused code
tophyr Jan 21, 2026
5dbf480
fix touch coordinate logic
tophyr Jan 21, 2026
0707850
synthesize UISystem mouse behaviors from touches
tophyr Jan 21, 2026
a162be9
signal start of text input to SDL
tophyr Jan 21, 2026
d01b243
Extract SDL <-> Game coordinate converters
tophyr Jan 22, 2026
cc7c070
Adjust active window to SDL "safe area"
tophyr Jan 22, 2026
8776142
fix build
tophyr Jan 22, 2026
83aae9f
adjust github CI to pre-build hogmaker for linux-cross-arm64
tophyr Jan 23, 2026
d76868b
add better documentation around hogmaker build
tophyr Jan 23, 2026
f4a229b
get rekt cmake
tophyr Jan 23, 2026
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
34 changes: 25 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
cc: gcc
cxx: g++
name: Linux-cross-arm64
- runner: ubuntu-22.04
name: android
build_type:
- Debug
- Release
Expand Down Expand Up @@ -101,12 +103,15 @@ jobs:
with:
vcpkgJsonGlob: vcpkg.json

- name: Configure cross-compiled build
if: ${{ matrix.os.preset == 'linux-cross-arm64' }}
run: |
cmake --preset linux
ninja -f build-${{ matrix.build_type }}.ninja -C builds/linux/ HogMaker
cmake --preset linux-cross-arm64 -DHogMaker_DIR=$PWD/builds/linux/ -DBUILD_TESTING=OFF -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=OFF -DUSE_EXTERNAL_PLOG=ON
- uses: actions/setup-java@v4
if: ${{ matrix.os.name == 'android' }}
with:
java-version: '17'
distribution: 'temurin'

- name: Build APK
if: ${{ matrix.os.name == 'android' }}
run: ./gradlew build

- name: Customize vcpkg to create macOS universal binary
if: ${{ matrix.os.preset == 'mac' }}
Expand All @@ -122,21 +127,31 @@ jobs:
p12-file-base64: ${{ secrets.MACOS_SIGNING_CERTIFICATE_P12 }}
p12-password: ${{ secrets.MACOS_SIGNING_CERTIFICATE_P12_PASSWORD }}

- name: Configure cross-compiled build
if: ${{ matrix.os.preset == 'linux-cross-arm64' }}
run: |
cmake --preset linux
cmake --build --preset linux --target HogMaker --config Release
cmake --install builds/linux --prefix $PWD/builds/host_tools/ --config Release --component HostTools
cmake --preset linux-cross-arm64 -DHOGMAKE_BINARY=$PWD/builds/host_tools/HogMaker -DBUILD_TESTING=OFF -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=OFF -DUSE_EXTERNAL_PLOG=ON

- name: Configure CMake
if: ${{ matrix.os.preset != 'linux-cross-arm64' }}
if: ${{ matrix.os.name != 'android' && matrix.os.preset != 'linux-cross-arm64' }}
env:
CC: ${{ matrix.os.cc }}
CXX: ${{ matrix.os.cxx }}
run: cmake --preset ${{ matrix.os.preset }} -DCODESIGN_IDENTITY=${{ secrets.MACOS_SIGNING_IDENTITY }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=ON -DUSE_EXTERNAL_PLOG=ON
run: cmake --preset ${{ matrix.os.preset }} -DCODESIGN_IDENTITY=${{ secrets.MACOS_SIGNING_IDENTITY }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=ON -DUSE_EXTERNAL_PLOG=ON -DBUILD_TESTING=${{ matrix.os.preset == 'linux-cross-arm64' && 'OFF' || 'ON' }}

- name: Build ${{ matrix.build_type }}
if: ${{ matrix.os.name != 'android' }}
run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }} --verbose

- name: Run ${{ matrix.build_type }} Unittests
if: ${{ matrix.os.preset != 'linux-cross-arm64' }}
if: ${{ matrix.os.preset != 'linux-cross-arm64' && matrix.os.name != 'android' }}
run: ctest --preset ${{ matrix.os.preset }} -C ${{ matrix.build_type }}

- name: Local install
if: ${{ matrix.os.name != 'android' }}
# There no cmake install presets so install in traditional way
run: cmake --install builds/${{ matrix.os.preset }}/ --config ${{ matrix.build_type }}

Expand All @@ -160,6 +175,7 @@ jobs:
mv builds/${{ matrix.os.preset }}/Descent3-${{ matrix.build_type }}-${{ matrix.os.name }}.dmg builds/${{ matrix.os.preset }}/installed/

- name: Upload Artifacts
if: ${{ matrix.os.name != 'android' }}
uses: actions/upload-artifact@v4
with:
name: Descent3_${{ matrix.build_type }}_${{ matrix.os.name }}
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,10 @@ build[s]

# Ignore autogenerated git-hash.txt file, generated for packaging purposes
git-hash.txt

# Android build bits
.gradle/*
android/.cxx/*
android/build/*
build/*
local.properties
7 changes: 5 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ mkdir build-native
cd build-native
cmake ..
cmake --build . --target HogMaker
cmake --install . --prefix . --component HostTools
```

Now, you are ready for cross-compilation. Create a new cross-compilation build directory and configure the project in it, but this time specify the location of the HogMaker native executable just built, as well as the [toolchain file](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#id14) location. This enables the cross-compilation environment. An example toolchain file is provided for a Linux ARM64 build at `cmake/toolchains/linux-aarch64-gcc-toolchain.cmake`. The custom toolchain system can be used in combination with VCPKG to build all dependencies for the target system.
Feel free to omit the `--target HogMaker` if you want to build the entire Descent3 project, or the `cmake --install` step if you don't mind finding the HogMaker build location yourself (it will vary between build generators like Ninja vs Make).

Once you have a HogMaker binary runnable on your build system, you are ready for cross-compilation. Create a new cross-compilation build directory and configure the project in it, but this time specify the location of the HogMaker native executable just built, as well as the [toolchain file](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#id14) location. This enables the cross-compilation environment. An example toolchain file is provided for a Linux ARM64 build at `cmake/toolchains/linux-aarch64-gcc-toolchain.cmake`. The custom toolchain system can be used in combination with VCPKG to build all dependencies for the target system.

```shell
mkdir build-cross
cd build-cross
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/MyToolChain.cmake -DHogMaker_DIR=../build-native/ ..
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/MyToolChain.cmake -DHOGMAKER_BINARY=../build-native/HogMaker ..
cmake --build .
```

Expand Down
30 changes: 24 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ 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 (CMAKE_SYSTEM_NAME STREQUAL "Android")
if (ANDROID_ABI MATCHES "arm64-v8a")
set(VCPKG_TARGET_TRIPLET "arm64-android" CACHE STRING "" FORCE)
elseif(ANDROID_ABI MATCHES "armeabi-v7a")
set(VCPKG_TARGET_TRIPLET "arm-android" CACHE STRING "" FORCE)
elseif(ANDROID_ABI MATCHES "x86_64")
set(VCPKG_TARGET_TRIPLET "x64-android" CACHE STRING "" FORCE)
elseif(ANDROID_ABI MATCHES "x86")
set(VCPKG_TARGET_TRIPLET "x86-android" CACHE STRING "" FORCE)
else()
message(FATAL_ERROR "ANDROID_ABI not set or not recognized")
endif()

set(ENV{ANDROID_NDK_HOME} ${CMAKE_ANDROID_NDK})
endif()

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

Expand Down Expand Up @@ -151,6 +167,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(HOG_NAME "osx")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(HOG_NAME "win")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(HOG_NAME "android")
endif()

# rebuild d3_version.h every time
Expand Down Expand Up @@ -206,6 +224,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message("Building for macOS")
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 "Android")
message("Building for Android")
add_compile_definitions(POSIX ANDROID _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-android.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 Down Expand Up @@ -310,12 +333,7 @@ endif()

add_subdirectory(Descent3)

if (CMAKE_CROSSCOMPILING)
find_package(HogMaker REQUIRED)
else()
add_subdirectory(tools)
endif()

add_subdirectory(tools)
add_subdirectory(netcon)
add_subdirectory(netgames)
add_subdirectory(scripts)
Expand Down
9 changes: 7 additions & 2 deletions Descent3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,13 @@ endif()

file(GLOB_RECURSE INCS "../lib/*.h")

add_executable(Descent3 WIN32 MACOSX_BUNDLE ${D3Icon} ${HEADERS} ${CPPS} ${INCS} ${MANIFEST} ${RC_FILE})
if(ANDROID)
add_library(Descent3 MODULE ${HEADERS} ${CPPS} ${INCS}
)
else()
add_executable(Descent3 WIN32 MACOSX_BUNDLE ${D3Icon} ${HEADERS} ${CPPS} ${INCS} ${MANIFEST} ${RC_FILE})
install(TARGETS Descent3 RUNTIME BUNDLE DESTINATION .)
endif()
target_link_libraries(Descent3 PRIVATE
SDL3::SDL3
2dlib
Expand Down Expand Up @@ -369,7 +375,6 @@ add_dependencies(Descent3
tanarchy
)

install(TARGETS Descent3 RUNTIME BUNDLE DESTINATION .)
if(MSVC)
install(FILES $<TARGET_PDB_FILE:Descent3> DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
Expand Down
2 changes: 1 addition & 1 deletion Descent3/CtlCfgElem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ int cfg_element_ui::DoUI() {
quit = true;
}

DoUIFrameWithoutInput();
DoUIFrame(false);
rend_Flip();

if (GetUIFrameResult() == NEWUIRES_FORCEQUIT) {
Expand Down
2 changes: 1 addition & 1 deletion Descent3/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ void GameRenderFrame(void) {

// Do UI Frame
if (Game_interface_mode == GAME_INTERFACE && !Menu_interface_mode) {
DoUIFrameWithoutInput();
DoUIFrame(false);
rend_Flip();
}

Expand Down
4 changes: 2 additions & 2 deletions Descent3/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ struct video_menu {
std::string res = Video_res_list[Current_video_resolution_id].getName();
auto alloc_size = std::max(res.size() + 1, static_cast<size_t>(15));
resolution_string = sheet->AddChangeableText(alloc_size);
snprintf(resolution_string, alloc_size, res.c_str());
snprintf(resolution_string, alloc_size, "%s", res.c_str());
sheet->AddLongButton("Change", IDV_CHANGE_RES_WINDOW);

fullscreen = sheet->AddLongCheckBox("Fullscreen", Game_fullscreen);
Expand Down Expand Up @@ -905,7 +905,7 @@ struct video_menu {
resolution_changed = true;
Current_video_resolution_id = newindex;
std::string res = Video_res_list[Current_video_resolution_id].getName();
snprintf(resolution_string, res.size() + 1, res.c_str());
snprintf(resolution_string, res.size() + 1, "%s", res.c_str());
}
}

Expand Down
2 changes: 1 addition & 1 deletion Descent3/d3movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int mve_PlayMovie(const std::filesystem::path &pMovieName, oeApplication *pApp)

// check for bail
int key = ddio_KeyInKey();
if (key == KEY_ESC) {
if (key == KEY_ESC || !ddio_GetCurrentTouches().empty()) {
aborted = true;
break;
}
Expand Down
31 changes: 3 additions & 28 deletions Descent3/newui_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ int DoUI() {
}

// does one frame of ui.
void DoUIFrame() {
void DoUIFrame(bool do_input) {
if (Multi_bail_ui_menu) {
UI_frame_result = NEWUIRES_FORCEQUIT;
} else {
Expand All @@ -629,40 +629,15 @@ void DoUIFrame() {
Sound_system.EndSoundFrame();
}

UI_frame_result = ui_DoFrame();
UI_frame_result = ui_DoFrame(do_input);
}

if (UI_input.printscreen) {
if (do_input && UI_input.printscreen) {
UI_input.printscreen = false;
DoScreenshot();
}
}

// does one frame of ui.
void DoUIFrameWithoutInput() {
if (Multi_bail_ui_menu) {
UI_frame_result = NEWUIRES_FORCEQUIT;
} else {
if (UI_callback)
(*UI_callback)();

if (GetFunctionMode() == MENU_MODE) {
tMusicSeqInfo music_info;

Sound_system.BeginSoundFrame(false);

music_info.frametime = UIFrameTime;
music_info.player_dead = false;
music_info.started_level = false;
D3MusicDoFrame(&music_info);

Sound_system.EndSoundFrame();
}

UI_frame_result = ui_DoFrame(false);
}
}

int GetUIFrameResult() { return UI_frame_result; }

// sets the callback for background rendering of desktop for UI
Expand Down
5 changes: 1 addition & 4 deletions Descent3/newui_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ void (*GetUICallback())();
int DoUI();

// does one frame of UI input (returns result.)
void DoUIFrame();

// does one frame of UI without polling input.
void DoUIFrameWithoutInput();
void DoUIFrame(bool do_input = true);

// gets frame result of ui input.
int GetUIFrameResult();
Expand Down
39 changes: 5 additions & 34 deletions Descent3/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
#include <filesystem>
#include <map>

#ifndef WIN32
#ifdef WIN32
#define SDL_MAIN_HANDLED
#else
#include <unistd.h>
#include <csignal>
#endif

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

#include "appdatabase.h"
#include "application.h"
Expand Down Expand Up @@ -176,37 +179,6 @@ class oeD3LnxDatabase final : public oeLnxAppDatabase {
}
};

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);

bool SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event) {
switch (event->type) {
case SDL_EVENT_KEY_UP:
case SDL_EVENT_KEY_DOWN:
return (sdlKeyFilter(event));
case SDL_EVENT_JOYSTICK_BALL_MOTION:
case SDL_EVENT_MOUSE_MOTION:
return (sdlMouseMotionFilter(event));
case SDL_EVENT_MOUSE_BUTTON_UP:
return (sdlMouseButtonUpFilter(event));
case SDL_EVENT_MOUSE_BUTTON_DOWN:
return (sdlMouseButtonDownFilter(event));
case SDL_EVENT_MOUSE_WHEEL:
return (sdlMouseWheelFilter(event));
case SDL_EVENT_QUIT:
SDL_Quit();
_exit(0);
break;
default:
break;
} // switch

return (1);
}

// ---------------------------------------------------------------------------
// Main
// creates all the OS objects and then runs Descent 3.
Expand Down Expand Up @@ -244,14 +216,13 @@ int main(int argc, char *argv[]) {
setenv("SDL_VIDEODRIVER", "dummy", 1);
#endif

SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
int rc = SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO);
if (!rc) {
LOG_FATAL.printf("SDL: SDL_Init() failed: %d: %s!", rc, SDL_GetError());
return (0);
}

// !!! FIXME: Don't use an event filter!
SDL_SetEventFilter(d3SDLEventFilter, nullptr);
install_signal_handlers();

// Initialize our OS Object. This could be a game dependant OS object, or a default OS object.
Expand Down
Loading
Loading