mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Migrate the Android port to SDL2
This commit is contained in:
parent
fca60e2a41
commit
07fdf7158d
30 changed files with 217 additions and 1538 deletions
|
@ -1,4 +1,4 @@
|
|||
if(NOT ANDROID AND NOT APPLE)
|
||||
if(NOT APPLE)
|
||||
set(DEFAULT_SDL2 ON)
|
||||
endif()
|
||||
|
||||
|
@ -77,10 +77,9 @@ elseif(APPLE)
|
|||
set(DEVICE "OSX")
|
||||
elseif(ANDROID)
|
||||
add_definitions(-D_IRR_ANDROID_PLATFORM_)
|
||||
if(USE_SDL2)
|
||||
message(FATAL_ERROR "SDL2 device is not (yet) supported on Android")
|
||||
if(NOT USE_SDL2)
|
||||
message(FATAL_ERROR "The Android build requires SDL2")
|
||||
endif()
|
||||
set(DEVICE "ANDROID")
|
||||
elseif(EMSCRIPTEN)
|
||||
add_definitions(-D_IRR_EMSCRIPTEN_PLATFORM_ -D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||
set(LINUX_PLATFORM TRUE)
|
||||
|
@ -131,7 +130,10 @@ endif()
|
|||
# OpenGL
|
||||
|
||||
if(USE_SDL2)
|
||||
option(ENABLE_OPENGL3 "Enable OpenGL 3+" TRUE)
|
||||
if(NOT ANDROID)
|
||||
set(DEFAULT_OPENGL3 TRUE)
|
||||
endif()
|
||||
option(ENABLE_OPENGL3 "Enable OpenGL 3+" ${DEFAULT_OPENGL3})
|
||||
else()
|
||||
set(ENABLE_OPENGL3 FALSE)
|
||||
endif()
|
||||
|
@ -142,13 +144,10 @@ else()
|
|||
option(ENABLE_OPENGL "Enable OpenGL" TRUE)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN OR APPLE)
|
||||
if(USE_SDL2 OR EMSCRIPTEN OR APPLE)
|
||||
set(ENABLE_GLES1 FALSE)
|
||||
else()
|
||||
if(ANDROID)
|
||||
set(DEFAULT_GLES1 TRUE)
|
||||
endif()
|
||||
option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1})
|
||||
option(ENABLE_GLES1 "Enable OpenGL ES" FALSE)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
@ -188,19 +187,16 @@ if(ENABLE_OPENGL3)
|
|||
endif()
|
||||
|
||||
if(ENABLE_GLES1)
|
||||
if (USE_SDL2)
|
||||
message(FATAL_ERROR "OpenGL ES 1 is not supported with SDL2")
|
||||
endif()
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES1_)
|
||||
set(OPENGLES_DIRECT_LINK TRUE)
|
||||
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$")
|
||||
if(DEVICE MATCHES "^(WINDOWS|X11)$")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLES2)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
|
||||
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN)
|
||||
if(DEVICE MATCHES "^(WINDOWS|X11)$" OR EMSCRIPTEN)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -248,11 +244,15 @@ endif()
|
|||
if(ENABLE_GLES2)
|
||||
find_package(OpenGLES2 REQUIRED)
|
||||
endif()
|
||||
if(ENABLE_OPENGL OR ENABLE_OPENGL3)
|
||||
if(ENABLE_OPENGL)
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
if(USE_SDL2)
|
||||
find_package(SDL2 REQUIRED)
|
||||
if(NOT ANDROID)
|
||||
find_package(SDL2 REQUIRED)
|
||||
else()
|
||||
# provided by MinetestAndroidLibs.cmake
|
||||
endif()
|
||||
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
|
||||
|
||||
# unfortunately older SDL does not provide its version to cmake, so check header.
|
||||
|
@ -323,7 +323,6 @@ set(link_includes
|
|||
${OPENGLES2_INCLUDE_DIR}
|
||||
${EGL_INCLUDE_DIR}
|
||||
|
||||
"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>"
|
||||
"$<$<BOOL:${USE_X11}>:${X11_INCLUDE_DIR}>"
|
||||
)
|
||||
|
||||
|
@ -453,14 +452,7 @@ if(ENABLE_OPENGL3)
|
|||
target_compile_definitions(IRROTHEROBJ PRIVATE ENABLE_OPENGL3)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
target_sources(IRROTHEROBJ PRIVATE
|
||||
Android/CIrrDeviceAndroid.cpp
|
||||
Android/CAndroidAssetReader.cpp
|
||||
Android/CAndroidAssetFileArchive.cpp
|
||||
Android/CKeyEventWrapper.cpp
|
||||
)
|
||||
elseif(APPLE)
|
||||
if(APPLE)
|
||||
# Build all IRROTHEROBJ sources as objc++, including the .cpp's
|
||||
set_target_properties(IRROTHEROBJ PROPERTIES COMPILE_OPTIONS "-xobjective-c++")
|
||||
target_sources(IRROTHEROBJ PRIVATE
|
||||
|
@ -535,7 +527,8 @@ target_link_libraries(IrrlichtMt PRIVATE
|
|||
"$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARY}>"
|
||||
${EGL_LIBRARY}
|
||||
|
||||
"$<$<PLATFORM_ID:Android>:-landroid -llog>"
|
||||
# incl. transitive SDL2 dependencies for static linking
|
||||
"$<$<PLATFORM_ID:Android>:-landroid -llog -lGLESv2 -lGLESv1_CM -lOpenSLES>"
|
||||
${COCOA_LIB}
|
||||
${IOKIT_LIB}
|
||||
"$<$<PLATFORM_ID:Windows>:gdi32>"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue