Skip to content

Commit

Permalink
Merge branch 'master' into sprite-loader-scalefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Feb 23, 2024
2 parents f7fbaae + a6e1727 commit 9f2900c
Show file tree
Hide file tree
Showing 89 changed files with 5,498 additions and 673 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Checks: '
,-fuchsia-multiple-inheritance,
,-fuchsia-overloaded-operator,
,-fuchsia-statically-constructed-objects,
,-fuchsia-trailing-return,
,-google-global-names-in-headers,
,-google-readability-todo,
,-google-runtime-int,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
build:
runs-on: [ubuntu-latest]
container:
image: registry.gitlab.com/jhasse/android-ndk-docker:r26
image: registry.gitlab.com/jhasse/android-ndk-docker:r26b
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: make -C android
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- name: Install dependencies
run: microdnf install -y git graphviz doxygen cmake make tar xz rsync
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout submodules
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
sudo apt install libgl1-mesa-dev libfreetype6-dev libfontconfig1-dev libxxf86vm-dev libpng-dev libvorbis-dev libopenal-dev g++ libwebp-dev git libsdl2-dev ninja-build
sudo apt install libgl1-mesa-dev libfreetype6-dev libfontconfig1-dev libxxf86vm-dev libpng-dev libvorbis-dev g++ libwebp-dev git libsdl2-dev ninja-build
- name: Configure with CMake and GCC
run: cmake -Bbuild -G"Ninja Multi-Config"
- name: Build Debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: |
brew install sdl2 freetype libvorbis webp pkg-config ninja
Expand Down
50 changes: 47 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,60 @@
name: Windows
on: [push]
jobs:
clang-cl:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: Configure
run: cmake -Bbuild -G"Ninja Multi-Config" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl
- name: Build (Debug)
run: cmake --build build --config Debug
- name: Unittest (Debug)
run: |
build/Debug/jngl-unittest Drawable
build/Debug/jngl-unittest ImageData
build/Debug/jngl-unittest FinallyTest
build/Debug/jngl-unittest halfLoadTest
build/Debug/jngl-unittest getBinaryPath
build/Debug/jngl-unittest readAsset
- name: Build (Release)
run: cmake --build build --config Release
- name: Unittest (Release)
run: |
build/Release/jngl-unittest Drawable
build/Release/jngl-unittest ImageData
build/Release/jngl-unittest FinallyTest
build/Release/jngl-unittest halfLoadTest
build/Release/jngl-unittest getBinaryPath
build/Release/jngl-unittest readAsset
msvc:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Configure
run: cmake -Bbuild
- name: Build (Debug)
run: cmake --build build --config Debug
- name: Unittest (Debug)
run: |
build/Debug/jngl-unittest Drawable
build/Debug/jngl-unittest ImageData
build/Debug/jngl-unittest FinallyTest
build/Debug/jngl-unittest halfLoadTest
build/Debug/jngl-unittest getBinaryPath
build/Debug/jngl-unittest readAsset
- name: Build (Release)
run: cmake --build build --config Release
- name: Unittest (Release)
run: |
build/Release/jngl-unittest Drawable
build/Release/jngl-unittest ImageData
build/Release/jngl-unittest FinallyTest
build/Release/jngl-unittest halfLoadTest
build/Release/jngl-unittest getBinaryPath
build/Release/jngl-unittest readAsset
- name: Configure (UWP)
run: cmake -Bbuild-uwp -DCMAKE_SYSTEM_NAME=WindowsStore '-DCMAKE_SYSTEM_VERSION=10.0'
- name: Build (UWP, Debug)
Expand All @@ -24,8 +68,8 @@ jobs:
image: registry.fedoraproject.org/fedora-minimal:37
steps:
- name: Install dependencies
run: microdnf install -y cmake ninja-build mingw64-pkg-config mingw64-libvorbis mingw64-SDL2 mingw64-fontconfig mingw64-libwebp mingw64-dlfcn mingw64-openal-soft mingw32-nsis mingw64-gcc-c++ tar gzip
- uses: actions/checkout@v3
run: microdnf install -y cmake ninja-build mingw64-pkg-config mingw64-libvorbis mingw64-SDL2 mingw64-fontconfig mingw64-libwebp mingw64-dlfcn mingw32-nsis mingw64-gcc-c++ tar gzip
- uses: actions/checkout@v4
- name: Build with CMake and GCC
run: |
mingw64-cmake -Bbuild-windows -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=0 -DJNGL_SDL2=1
Expand Down
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ image: registry.fedoraproject.org/fedora-minimal:38
linux:
stage: build
script:
- microdnf install -y cmake ninja-build gcc-c++ fontconfig-devel freetype-devel libvorbis-devel libwebp-devel SDL2-devel openal-soft-devel libtheora-devel clang util-linux >/dev/null
- microdnf install -y cmake ninja-build gcc-c++ fontconfig-devel freetype-devel libvorbis-devel libwebp-devel SDL2-devel libtheora-devel clang util-linux >/dev/null
- CXXFLAGS=-fdiagnostics-color cmake -Bbuild -GNinja
- cd build
- ninja
Expand All @@ -29,14 +29,14 @@ linux:
mingw:
stage: build
script:
- microdnf install -y gcc-c++ cmake ninja-build mingw64-pkg-config mingw64-libvorbis mingw64-SDL2 mingw64-fontconfig mingw64-libwebp mingw64-dlfcn mingw64-openal-soft mingw64-gcc-c++ > /dev/null
- microdnf install -y cmake ninja-build mingw64-pkg-config mingw64-libvorbis mingw64-SDL2 mingw64-fontconfig mingw64-libwebp mingw64-dlfcn mingw64-gcc-c++ > /dev/null
- mingw64-cmake -GNinja -Bbuild-debug -DCMAKE_BUILD_TYPE=Debug
- ninja -C build-debug
- mingw64-cmake -GNinja -Bbuild-release -DCMAKE_BUILD_TYPE=Release
- ninja -C build-release

android:
image: registry.gitlab.com/jhasse/android-ndk-docker:r26
image: registry.gitlab.com/jhasse/android-ndk-docker:r26b
stage: build
script:
- make -C android
Expand Down
95 changes: 42 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

file(GLOB SRC src/*.cpp src/jngl/*.cpp)
file(GLOB SRC src/*.cpp src/jngl/*.cpp
src/audio/*.cpp
src/audio/effect/*.cpp
)
add_library(jngl ${SRC})
file(GLOB HEADERS src/*.hpp src/jngl/*.hpp)
target_sources(jngl PRIVATE ${HEADERS})
Expand Down Expand Up @@ -67,15 +70,13 @@ if(MSVC OR IOS OR ANDROID OR EMSCRIPTEN)
endif()
option(JNGL_BUILD_WEBP_FROM_SOURCE "Build libwebp from source instead of using the system version" ${JNGL_BUILD_WEBP_FROM_SOURCE_DEFAULT})

set(ALSOFT_TESTS OFF CACHE BOOL "Build and install test programs" FORCE)
set(ALSOFT_EXAMPLES OFF CACHE BOOL "Build and install example programs" FORCE)
set(ALSOFT_UTILS OFF CACHE BOOL "Build and install utility programs" FORCE)

if (ANDROID)
find_package(oboe REQUIRED CONFIG)
target_link_libraries(jngl PRIVATE oboe::oboe)
file(GLOB ANDROID_SOURCES src/android/*.cpp)
target_sources(jngl PRIVATE ${ANDROID_SOURCES})
target_sources(jngl PRIVATE ${ANDROID_SOURCES} src/audio/android/engine.cpp)
elseif(IOS)
file(GLOB SRC src/ios/*.cpp src/ios/*.mm src/ios/*.h)
file(GLOB SRC src/ios/*.cpp src/ios/*.mm src/audio/ios/Engine.mm src/ios/*.h)
target_sources(jngl PRIVATE ${SRC} src/mac/message.cpp)
elseif (UNIX)
file(GLOB SRC src/sdl/*.cpp src/sdl/controller/SdlController.cpp)
Expand All @@ -93,6 +94,7 @@ elseif (UNIX)
else()
file(GLOB SRC src/linux/*.cpp src/linux/*.c)
target_sources(jngl PRIVATE ${SRC})
target_link_libraries(jngl PRIVATE atomic)
endif()

target_link_libraries(jngl PRIVATE $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>)
Expand Down Expand Up @@ -189,22 +191,12 @@ endif()
if(ANDROID)
target_compile_definitions(jngl PRIVATE NOPNG)

CPMAddPackage(NAME openal
URL https://github.com/kcat/openal-soft/archive/refs/tags/1.21.1.zip
URL_HASH SHA1=1442363faf47a5a7cd6287513068ecd6c70e747e
OPTIONS
"LIBTYPE STATIC"
"ALSOFT_INSTALL_CONFIG OFF"
"ALSOFT_INSTALL_HRTF_DATA OFF"
"ALSOFT_INSTALL_AMBDEC_PRESETS OFF"
"ALSOFT_BACKEND_WAVE OFF"
"ALSOFT_CPUEXT_NEON OFF"
)
set(OPENAL_LIBRARY OpenAL)

target_include_directories(jngl PUBLIC ${ANDROID_NDK}/sources/android/native_app_glue)
target_include_directories(jngl PRIVATE ${OGG_INCLUDE_DIRS} ${VORBIS_SRC_DIR}/include)
else()
if(NOT IOS)
target_sources(jngl PRIVATE src/audio/sdl/engine.cpp)
endif()
if(UNIX AND NOT IOS AND NOT EMSCRIPTEN)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
Expand Down Expand Up @@ -232,46 +224,51 @@ else()
if(MSVC)
target_compile_definitions(jngl PUBLIC _USE_MATH_DEFINES)
if(JNGL_SDL2)
set(SDL_SENSOR OFF CACHE BOOL "" FORCE) # doesn't work with UWP
FetchContent_Declare(sdl2
CPMAddPackage(NAME sdl2
URL https://www.libsdl.org/release/SDL2-2.28.4.zip
URL_HASH SHA1=0d9e0da0e935c4f0524cfd16d47d38b6045b9573
OPTIONS
"SDL_SENSOR OFF" # doesn't work with UWP
)
else()
CPMAddPackage(NAME sdl2
URL https://www.libsdl.org/release/SDL2-2.28.4.zip
URL_HASH SHA1=0d9e0da0e935c4f0524cfd16d47d38b6045b9573
OPTIONS
"SDL_ATOMIC OFF"
"SDL_CPUINFO ON"
"SDL_DLOPEN OFF"
"SDL_FILE OFF"
"SDL_FILESYSTEM OFF"
"SDL_HAPTIC OFF"
"SDL_LOADSO ON"
"SDL_LOCALE OFF"
"SDL_POWER OFF"
"SDL_RENDER OFF"
"SDL_SENSOR OFF"
"SDL_SHARED OFF"
"SDL_TIMERS OFF"
)
FetchContent_MakeAvailable(sdl2)
target_link_libraries(jngl PRIVATE SDL2-static)
endif()
target_link_libraries(jngl PRIVATE SDL2-static)
if(WINDOWS_STORE)
target_compile_definitions(jngl PUBLIC JNGL_UWP)
target_include_directories(jngl PUBLIC ${sdl2_SOURCE_DIR}/include ${sdl2_BINARY_DIR}/include) # TODO: This should be PRIVATE
FetchContent_Declare(openal
GIT_REPOSITORY https://github.com/jhasse/openal-soft-winphone
GIT_TAG e4f3681316b1e8d8d68dfc31b1fc952d9bba085d)
target_link_options(jngl PUBLIC $<IF:$<CONFIG:Debug>,/defaultlib:vccorlibd.lib /defaultlib:msvcrtd.lib,/defaultlib:vccorlib.lib /defaultlib:msvcrt.lib>)
else()
FetchContent_Declare(openal
URL https://github.com/kcat/openal-soft/archive/refs/tags/1.21.1.zip
URL_HASH SHA1=1442363faf47a5a7cd6287513068ecd6c70e747e)
set(ALSOFT_NO_CONFIG_UTIL ON CACHE BOOL "Disable building the alsoft-config utility" FORCE)
set(LIBTYPE "STATIC" CACHE STRING "" FORCE)
target_compile_definitions(jngl PRIVATE AL_LIBTYPE_STATIC)
endif()
FetchContent_MakeAvailable(openal)
set(OPENAL_LIBRARY OpenAL)

elseif(IOS)
target_compile_options(jngl PRIVATE -Wno-deprecated-declarations) # OpenAL
target_compile_definitions(jngl PRIVATE IOS)
target_compile_definitions(jngl PUBLIC GLES_SILENCE_DEPRECATION)
target_include_directories(jngl PUBLIC include/ios)
find_library(IOS_OPENGLES OpenGLES)
find_library(IOS_OPENAL OpenAL)
find_library(IOS_QUARTZCORE QuartzCore)
find_library(IOS_UIKIT UIKit)
find_library(IOS_AVFOUNDATION AVFoundation)
find_library(IOS_GAMECONTROLLER GameController)
find_library(IOS_AudioToolbox AudioToolbox)
target_link_libraries(jngl PRIVATE
${IOS_OPENGLES} ${IOS_OPENAL} ${IOS_QUARTZCORE} ${IOS_UIKIT} ${IOS_AVFOUNDATION}
${IOS_GAMECONTROLLER}
${IOS_OPENGLES} ${IOS_QUARTZCORE} ${IOS_UIKIT} ${IOS_AVFOUNDATION}
${IOS_GAMECONTROLLER} ${IOS_AudioToolbox}
)

if(NOT hasParent)
Expand All @@ -287,8 +284,6 @@ else()
set_target_properties(jngl-test PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/data/ios/jngl-test.in.plist")
endif()
else()
find_package(OpenAL REQUIRED)

if(NOT JNGL_BUILD_WEBP_FROM_SOURCE)
find_package(WebP)
if(WebP_FOUND)
Expand All @@ -300,11 +295,9 @@ else()

find_package(PkgConfig)
if(PkgConfig_FOUND)
if(JNGL_SDL2)
pkg_check_modules(SDL2 REQUIRED sdl2)
target_include_directories(jngl PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(jngl PRIVATE ${SDL2_LINK_LIBRARIES})
endif()
pkg_check_modules(SDL2 REQUIRED sdl2)
target_include_directories(jngl PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(jngl PRIVATE ${SDL2_LINK_LIBRARIES})
if(JNGL_VIDEO)
if(APPLE)
# On macOS we'll build theora from source, since Homebrew's version crashes due
Expand Down Expand Up @@ -401,10 +394,6 @@ if(JNGL_BUILD_WEBP_FROM_SOURCE)
)
target_include_directories(jngl PRIVATE ${webp_SOURCE_DIR}/src)
target_link_libraries(jngl PRIVATE webpdecode webpdspdecode webputilsdecode)
# Note: For some reason it's important to add webp last for MSVC. Otherwise other CMake
# projects linking JNGL will get:
# MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol WinMain
# referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
endif()

if(ANDROID OR IOS OR APPLE OR WINDOWS_STORE)
Expand Down Expand Up @@ -435,7 +424,7 @@ endif()

target_include_directories(jngl PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_directories(jngl PUBLIC ${FREETYPE_LIBRARY_DIRS})
target_link_libraries(jngl PUBLIC ${FREETYPE_LIBRARIES} ${OPENAL_LIBRARY})
target_link_libraries(jngl PUBLIC ${FREETYPE_LIBRARIES})

if(NOT hasParent AND NOT WINDOWS_STORE)
include(CTest)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ cmake --build build

```
sudo apt-get install libgl1-mesa-dev libfreetype6-dev libfontconfig1-dev libxxf86vm-dev \
libpng-dev libvorbis-dev libopenal-dev cmake g++ \
libpng-dev libvorbis-dev cmake g++ \
libwebp-dev git libsdl2-dev
```

### Fedora

```
sudo dnf install fontconfig-devel freetype-devel libvorbis-devel libwebp-devel \
cmake SDL2-devel openal-soft-devel gcc-c++
cmake SDL2-devel gcc-c++
```

### Arch Linux

```
pacman -Syu --needed cmake gcc sdl2 pkg-config fontconfig libwebp openal libvorbis
pacman -Syu --needed cmake gcc sdl2 pkg-config fontconfig libwebp libvorbis
```

## Windows
Expand All @@ -50,10 +50,10 @@ pacman -Syu --needed cmake gcc sdl2 pkg-config fontconfig libwebp openal libvorb
Set up [MSYS2](https://www.msys2.org/) and install the following in a MinGW-w64 Win64 Shell:

```
pacman -Syu --needed mingw-w64-x86_64-gcc mingw-w64-x86_64-openal \
pacman -Syu --needed mingw-w64-x86_64-gcc \
mingw-w64-x86_64-freetype mingw-w64-x86_64-libvorbis mingw-w64-x86_64-libwebp \
mingw-w64-x86_64-dlfcn mingw-w64-x86_64-cmake make mingw-w64-x86_64-gdb \
mingw-w64-x86_64-libtheora
mingw-w64-x86_64-libtheora mingw-w64-x86_64-SDL2
```

### Visual Studio 2017 or newer
Expand Down
Loading

0 comments on commit 9f2900c

Please sign in to comment.