From 6aaedb813fa11ba0679c3051bc2eb28646b9506c Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 30 Aug 2025 16:53:58 -0700 Subject: Update to SDL3 --- .../SDL-3.2.20/android-project/app/jni/Android.mk | 1 + .../android-project/app/jni/Application.mk | 13 +++++++++ .../android-project/app/jni/CMakeLists.txt | 15 ++++++++++ .../android-project/app/jni/src/Android.mk | 19 ++++++++++++ .../android-project/app/jni/src/CMakeLists.txt | 34 ++++++++++++++++++++++ .../android-project/app/jni/src/YourSourceHere.c | 26 +++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 src/contrib/SDL-3.2.20/android-project/app/jni/Android.mk create mode 100644 src/contrib/SDL-3.2.20/android-project/app/jni/Application.mk create mode 100644 src/contrib/SDL-3.2.20/android-project/app/jni/CMakeLists.txt create mode 100644 src/contrib/SDL-3.2.20/android-project/app/jni/src/Android.mk create mode 100644 src/contrib/SDL-3.2.20/android-project/app/jni/src/CMakeLists.txt create mode 100644 src/contrib/SDL-3.2.20/android-project/app/jni/src/YourSourceHere.c (limited to 'src/contrib/SDL-3.2.20/android-project/app/jni') diff --git a/src/contrib/SDL-3.2.20/android-project/app/jni/Android.mk b/src/contrib/SDL-3.2.20/android-project/app/jni/Android.mk new file mode 100644 index 0000000..5053e7d --- /dev/null +++ b/src/contrib/SDL-3.2.20/android-project/app/jni/Android.mk @@ -0,0 +1 @@ +include $(call all-subdir-makefiles) diff --git a/src/contrib/SDL-3.2.20/android-project/app/jni/Application.mk b/src/contrib/SDL-3.2.20/android-project/app/jni/Application.mk new file mode 100644 index 0000000..80b73fd --- /dev/null +++ b/src/contrib/SDL-3.2.20/android-project/app/jni/Application.mk @@ -0,0 +1,13 @@ + +# Uncomment this if you're using STL in your project +# You can find more information here: +# https://developer.android.com/ndk/guides/cpp-support +# APP_STL := c++_shared + +APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 + +# Min runtime API level +APP_PLATFORM=android-21 + +# https://developer.android.com/guide/practices/page-sizes#update-packaging +APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true \ No newline at end of file diff --git a/src/contrib/SDL-3.2.20/android-project/app/jni/CMakeLists.txt b/src/contrib/SDL-3.2.20/android-project/app/jni/CMakeLists.txt new file mode 100644 index 0000000..404b87b --- /dev/null +++ b/src/contrib/SDL-3.2.20/android-project/app/jni/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.6) + +project(GAME) + +# SDL sources are in a subfolder named "SDL" +add_subdirectory(SDL) + +# Compilation of companion libraries +#add_subdirectory(SDL_image) +#add_subdirectory(SDL_mixer) +#add_subdirectory(SDL_ttf) + +# Your game and its CMakeLists.txt are in a subfolder named "src" +add_subdirectory(src) + diff --git a/src/contrib/SDL-3.2.20/android-project/app/jni/src/Android.mk b/src/contrib/SDL-3.2.20/android-project/app/jni/src/Android.mk new file mode 100644 index 0000000..61672d4 --- /dev/null +++ b/src/contrib/SDL-3.2.20/android-project/app/jni/src/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := main + +# Add your application source files here... +LOCAL_SRC_FILES := \ + YourSourceHere.c + +SDL_PATH := ../SDL # SDL + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include # SDL + +LOCAL_SHARED_LIBRARIES := SDL3 + +LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid # SDL + +include $(BUILD_SHARED_LIBRARY) diff --git a/src/contrib/SDL-3.2.20/android-project/app/jni/src/CMakeLists.txt b/src/contrib/SDL-3.2.20/android-project/app/jni/src/CMakeLists.txt new file mode 100644 index 0000000..df0a4d0 --- /dev/null +++ b/src/contrib/SDL-3.2.20/android-project/app/jni/src/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.6) + +project(my_app) + +if(NOT TARGET SDL3::SDL3) + find_package(SDL3 CONFIG) +endif() + +if(NOT TARGET SDL3::SDL3) + find_library(SDL3_LIBRARY NAMES "SDL3") + find_path(SDL3_INCLUDE_DIR NAMES "SDL3/SDL.h") + add_library(SDL3::SDL3 UNKNOWN IMPORTED) + set_property(TARGET SDL3::SDL3 PROPERTY IMPORTED_LOCATION "${SDL3_LIBRARY}") + set_property(TARGET SDL3::SDL3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SDL3_INCLUDE_DIR}") +endif() + +if(NOT TARGET SDL3::SDL3) + message(FATAL_ERROR "Cannot find SDL3. + +Possible ways to fix this: +- Use a SDL3 Android aar archive, and configure gradle to use it: prefab is required. +- Add add_subdirectory(path/to/SDL) to your CMake script, and make sure a vendored SDL is present there. +") +endif() + +add_library(main SHARED + YourSourceHere.c +) + +#https://developer.android.com/guide/practices/page-sizes#update-packaging +target_link_options(main PRIVATE "-Wl,-z,max-page-size=16384") +target_link_options(main PRIVATE "-Wl,-z,common-page-size=16384") + +target_link_libraries(main PRIVATE SDL3::SDL3) diff --git a/src/contrib/SDL-3.2.20/android-project/app/jni/src/YourSourceHere.c b/src/contrib/SDL-3.2.20/android-project/app/jni/src/YourSourceHere.c new file mode 100644 index 0000000..87b8297 --- /dev/null +++ b/src/contrib/SDL-3.2.20/android-project/app/jni/src/YourSourceHere.c @@ -0,0 +1,26 @@ +#include +#include + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* */ +/* Remove this source, and replace with your SDL sources */ +/* */ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +int main(int argc, char *argv[]) { + (void)argc; + (void)argv; + if (!SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init failed (%s)", SDL_GetError()); + return 1; + } + + if (!SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Hello World", + "!! Your SDL project successfully runs on Android !!", NULL)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_ShowSimpleMessageBox failed (%s)", SDL_GetError()); + return 1; + } + + SDL_Quit(); + return 0; +} -- cgit v1.2.3