chore(build): use SDL3

This commit is contained in:
phaneron 2025-04-12 04:38:19 -04:00
parent 9d04a35d87
commit b3c0734a9e
3286 changed files with 866354 additions and 554996 deletions

View file

@ -0,0 +1 @@
include $(call all-subdir-makefiles)

View file

@ -0,0 +1,10 @@
# 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-16

View file

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

View file

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

View file

@ -0,0 +1,29 @@
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
)
target_link_libraries(main PRIVATE SDL3::SDL3)

View file

@ -0,0 +1,26 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* */
/* 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;
}