diff --git a/README.md b/README.md index 8cc6d1a77..2eed32e57 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,9 @@ framework heavily focused on the development of rich graphical user interfaces. ### Cross platform functionality -* Official support for Linux, Windows, macOS and Android. +* Official support for Linux, Windows, macOS, Android and iOS. -* Exports to HTML5 using emscripten with some limitations. - -* iOS current support is limited but should work without issues. +* Exports to HTML5 using emscripten with some minor limitations. * Also works on BSD and Haiku. @@ -442,23 +440,59 @@ library. That file can be used in you projects. ### iOS -I've compiled the project for **iOS** many times in the past but there's not a -recent build of it, so it might fail. But you can get the scripts to build it in -`projects/ios/`. You can use `compile-all.sh` to generate a static build of eepp -( but you will need to update the `libs/ios/libSDL2.a` build with a more recent -one ). -You'll need some inspiration to make this work, but I promise that I'll work on -make this easier in the near future. -You can also try to build the project with -`premake5 --use-frameworks --os=ios xcode4`. That should give you a good -starting point, but won't build, it will need some minor tweaks. +The project provides two files to build the library and the demos. You can use +any of them depending on your needs. +The files are located in `projects/ios`: + +#### gen-xcode4-proj.sh script + +This script can be used to generate the xcode projects and solution of all the +included projects in eepp (demos, tools, shared lib, static lib, etc). It will +also download and build the SDL2 fat static library in order to be able to +reference the library to the project. After building the projects sadly you'll +need to make some minor changes to any/all of the projects you wan't to build +or test, since the project generated lacks some minor configurations. After +you run this script you'll need to open the solution located in +`make/ios/eepp.xcworkspace`. To build the static libraries you'll not find any +problem (that will work out of the box). But to test some of the examples it's +required to: + +##### Add the Info.plist file + +Select (click on the project name) the project you want to test, for example + `eepp-empty-window`. You will se several tabs/options, go to _Build Settings_, + and locate the option _Info.plist_ file, double click to edit and write: + `Info.plist`. This will indicate to read that file that is located in the same + directory than the project. The go to the tab _General_ and complete the + _Bundle Identifier_ with an identifier name of the app bundle that will be + generated, for this example you can use something like: `eepp-empty-window`. + That will allow you to build and run the project. + +#### Add resources to the project +This `eepp-empty-window` demo does not use any assets/resources, but other demos +will need to load assets, and this assets need to be added to the project in order +to be available to the app bundle. For example, the project `eepp-ui-hello-world`, +will require you to add the `assets` folder into the project. What you need to do +is: select the project and go to the _Build Phases_ tab, in _Copy Bundles Resources_ +click in the plus icon (+), then go to _Add Other..._ and locate and select the +`bin/assets/` folder and _Finish_. That should be enough. + +#### compile-all.sh script + +This script can be used to build the SDL2 and eepp as two fat static libraries +with arm64 and x86_64 architectures in it (arm64 for iPhone/iPad and x86_64 for +the simulators). To generate a release build pass `config=release` as a parameter +fo the script (`sh compile-all.sh config=release`). The built files will be +located in `libs/ios/`, as `libSDL2.a` and `libeepp.a` (or `libeepp-debug.a` for +debug build). This two files can be integrated in your project. ### emscripten You will first need to [download and install emscripten](https://emscripten.org/docs/getting_started/downloads.html). Then there's a script for building the **emscripten** project in -`projects/emscripten/make.sh`. That should be enough in **GNU/Linux** or -**macOS** ( only tested this on GNU/Linux ). +`projects/emscripten/make.sh`. Before running this script remember to set the +emsdk enviroment, it should be something like: `source /path/to/emsdk/emsdk_env.sh`. +That should be enough in **GNU/Linux** or **macOS** ( only tested this on GNU/Linux ). ## Author comment diff --git a/libs/ios/libSDL2.a b/libs/ios/libSDL2.a deleted file mode 100644 index 57ccf1fbb..000000000 Binary files a/libs/ios/libSDL2.a and /dev/null differ diff --git a/premake4.lua b/premake4.lua index 062f7b040..ee0ed5301 100644 --- a/premake4.lua +++ b/premake4.lua @@ -285,6 +285,7 @@ os_links = { } backends = { } static_backends = { } backend_selected = false +remote_sdl2_version = "SDL2-2.0.10" function build_base_configuration( package_name ) includedirs { "src/thirdparty/zlib" } @@ -489,7 +490,7 @@ function generate_os_links() elseif os.is_real("haiku") then multiple_insert( os_links, { "GL", "network" } ) elseif os.is_real("ios") then - multiple_insert( os_links, { "OpenGLES.framework", "AudioToolbox.framework", "CoreAudio.framework", "Foundation.framework", "CoreFoundation.framework", "UIKit.framework", "QuartzCore.framework", "CoreGraphics.framework" } ) + multiple_insert( os_links, { "OpenGLES.framework", "AudioToolbox.framework", "CoreAudio.framework", "Foundation.framework", "CoreFoundation.framework", "UIKit.framework", "QuartzCore.framework", "CoreGraphics.framework", "CoreMotion.framework", "AVFoundation.framework", "GameController.framework" } ) end if not _OPTIONS["with-mojoal"] then @@ -613,17 +614,17 @@ function set_ios_config() local sysroot_path = os.getenv("SYSROOTPATH") local framework_path = sysroot_path .. "/System/Library/Frameworks" local framework_libs_path = framework_path .. "/usr/lib" - local sysroot_ver = " -miphoneos-version-min=" .. os.getenv("IOSVERSION") .. " -isysroot " .. sysroot_path + local sysroot_ver = " -miphoneos-version-min=9.0 -isysroot " .. sysroot_path buildoptions { sysroot_ver .. " -I" .. sysroot_path .. "/usr/include" } linkoptions { sysroot_ver } libdirs { framework_libs_path } linkoptions { " -F" .. framework_path .. " -L" .. framework_libs_path .. " -isysroot " .. sysroot_path } - includedirs { "src/thirdparty/SDL2/include" } + includedirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" } end if _OPTIONS.platform == "ios-cross-arm7" or _OPTIONS.platform == "ios-cross-x86" then - includedirs { "src/thirdparty/SDL2/include" } + includedirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" } end end diff --git a/premake5.lua b/premake5.lua index 4f54da639..0ab479c74 100644 --- a/premake5.lua +++ b/premake5.lua @@ -89,6 +89,7 @@ backends = { } static_backends = { } backend_selected = false remote_sdl2_version = "SDL2-2.0.10" +remote_sdl2_devel_src_url = "https://libsdl.org/release/SDL2-2.0.10.zip" remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" function incdirs( dirs ) @@ -98,19 +99,28 @@ function incdirs( dirs ) includedirs { dirs } end +function download_and_extract_sdl(sdl_url) + print("Downloading: " .. sdl_url) + local dest_dir = "src/thirdparty/" + local local_file = dest_dir .. remote_sdl2_version .. ".zip" + local result_str, response_code = http.download(sdl_url, local_file) + if response_code == 200 then + print("Downloaded successfully to: " .. local_file) + zip.extract(local_file, dest_dir) + print("Extracted " .. local_file .. " into " .. dest_dir) + else + print("Failed to download: " .. sdl_url) + exit(1) + end +end + function download_and_extract_dependencies() - if _OPTIONS["windows-vc-build"] and not os.isdir("src/thirdparty/" .. remote_sdl2_version) then - print("Downloading: " .. remote_sdl2_devel_vc_url) - local dest_dir = "src/thirdparty/" - local local_file = dest_dir .. remote_sdl2_version .. ".zip" - local result_str, response_code = http.download(remote_sdl2_devel_vc_url, local_file) - if response_code == 200 then - print("Downloaded successfully to: " .. local_file) - zip.extract(local_file, dest_dir) - print("Extracted " .. local_file .. " into " .. dest_dir) - else - print("Failed to download: " .. remote_sdl2_rul) - exit(1) + if not os.isdir("src/thirdparty/" .. remote_sdl2_version) then + if _OPTIONS["windows-vc-build"] then + download_and_extract_sdl(remote_sdl2_devel_vc_url) + elseif os.istarget("ios") then + download_and_extract_sdl(remote_sdl2_devel_src_url) + os.execute("patch -t --forward -p1 -d src/thirdparty/SDL2-2.0.10/ < projects/ios/SDL2-sensors.patch") end end end @@ -124,10 +134,10 @@ function build_base_configuration( package_name ) filter "not system:windows" buildoptions{ "-fPIC" } - filter "configurations:debug" + filter "configurations:debug*" targetname ( package_name .. "-debug" ) - filter "configurations:release" + filter "configurations:release*" targetname ( package_name ) filter "action:not vs*" @@ -149,12 +159,12 @@ function build_base_cpp_configuration( package_name ) filter "action:not vs*" buildoptions { "-Wall" } - filter "configurations:debug" + filter "configurations:debug*" defines { "DEBUG" } symbols "On" targetname ( package_name .. "-debug" ) - filter "configurations:release" + filter "configurations:release*" optimize "Speed" targetname ( package_name ) end @@ -192,23 +202,23 @@ function build_link_configuration( package_name, use_ee_icon ) cppdialect "C++14" buildoptions { "-Wall" } - filter { "configurations:debug", "action:not vs*" } + filter { "configurations:debug*", "action:not vs*" } buildoptions{ "-Wno-long-long" } - filter { "configurations:release", "action:not vs*" } + filter { "configurations:release*", "action:not vs*" } buildoptions { "-fno-strict-aliasing -ffast-math" } - filter { "configurations:release", "action:not vs*", "system:not macosx" } + filter { "configurations:release*", "action:not vs*", "system:not macosx" } buildoptions { "-s" } - filter "configurations:debug" + filter "configurations:debug*" defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER" } targetname ( package_name .. "-debug" .. extension ) - filter "configurations:release" + filter "configurations:release*" targetname ( package_name .. extension ) - filter { "system:windows or system:ios", "action:not vs*" } + filter { "system:windows", "action:not vs*" } linkoptions { "-static-libgcc", "-static-libstdc++" } filter { "system:windows", "action:vs*" } @@ -253,7 +263,7 @@ function generate_os_links() elseif os.istarget("haiku") then multiple_insert( os_links, { "GL", "network" } ) elseif os.istarget("ios") then - multiple_insert( os_links, { "OpenGLES.framework", "AudioToolbox.framework", "CoreAudio.framework", "Foundation.framework", "CoreFoundation.framework", "UIKit.framework", "QuartzCore.framework", "CoreGraphics.framework" } ) + multiple_insert( os_links, { "OpenGLES.framework", "AudioToolbox.framework", "CoreAudio.framework", "Foundation.framework", "CoreFoundation.framework", "UIKit.framework", "QuartzCore.framework", "CoreGraphics.framework", "CoreMotion.framework", "AVFoundation.framework", "GameController.framework" } ) elseif os.istarget("android") then multiple_insert( os_links, { "GLESv1_CM", "GLESv2", "log" } ) end @@ -319,13 +329,13 @@ end function can_add_static_backend( name ) if _OPTIONS["with-static-backend"] then - local path = "libs/" .. os.target() .. "/lib" .. name .. ".a" - return os.isfile(path) + return true end + return false end function insert_static_backend( name ) - table.insert( static_backends, path.getrelative( "libs/" .. os.target(), "./" ) .. "/libs/" .. os.target() .. "/lib" .. name .. ".a" ) + table.insert( static_backends, "../../libs/" .. os.target() .. "/lib" .. name .. ".a" ) end function add_sdl2() @@ -333,6 +343,7 @@ function add_sdl2() if not can_add_static_backend("SDL2") then table.insert( link_list, get_backend_link_name( "SDL2" ) ) else + print("Using static backend") insert_static_backend( "SDL2" ) end @@ -349,44 +360,32 @@ end function set_ios_config() if os.istarget("ios") then - local err = false + local toolchainpath = os.getenv("TOOLCHAINPATH") + local iosversion = os.getenv("IOSVERSION") + local sysroot_path = os.getenv("SYSROOTPATH") if nil == os.getenv("TOOLCHAINPATH") then - print("You must set TOOLCHAINPATH enviroment variable.") - print("\tExample: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/") - err = true - end - - if nil == os.getenv("SYSROOTPATH") then - print("You must set SYSROOTPATH enviroment variable.") - print("\tExample: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk") - err = true + toolchainpath = os.outputof("xcrun -find -sdk iphonesimulator clang") end if nil == os.getenv("IOSVERSION") then - print("You must set IOSVERSION enviroment variable.") - print("\tExample: 5.0") - err = true + iosversion = os.outputof("xcrun --sdk iphonesimulator --show-sdk-version") end - if err then - os.exit(1) + if nil == os.getenv("SYSROOTPATH") then + local platform_path = os.outputof("xcrun --sdk iphonesimulator --show-sdk-platform-path") + sysroot_path = platform_path .. "/Developer/SDKs/iPhoneSimulator" .. iosversion .. ".sdk/" end - local sysroot_path = os.getenv("SYSROOTPATH") local framework_path = sysroot_path .. "/System/Library/Frameworks" local framework_libs_path = framework_path .. "/usr/lib" - local sysroot_ver = " -miphoneos-version-min=" .. os.getenv("IOSVERSION") .. " -isysroot " .. sysroot_path + local sysroot_ver = " -miphoneos-version-min=9.0 -isysroot " .. sysroot_path buildoptions { sysroot_ver .. " -I" .. sysroot_path .. "/usr/include" } linkoptions { sysroot_ver } libdirs { framework_libs_path } linkoptions { " -F" .. framework_path .. " -L" .. framework_libs_path .. " -isysroot " .. sysroot_path } - incdirs { "src/thirdparty/SDL2/include" } - end - - if _OPTIONS.platform == "ios-cross-arm7" or _OPTIONS.platform == "ios-cross-x86" then - incdirs { "src/thirdparty/SDL2/include" } + includedirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" } end end @@ -507,11 +506,6 @@ function build_eepp( build_name ) filter { "system:macosx", "action:xcode* or options:use-frameworks" } libdirs { "/System/Library/Frameworks", "/Library/Frameworks" } - filter "with-dynamic-freetype" - if os_findlib("freetype") then - table.insert( link_list, get_backend_link_name( "freetype" ) ) - end - filter "system:windows" files { "src/eepp/system/platform/win/*.cpp" } files { "src/eepp/network/platform/win/*.cpp" } @@ -532,12 +526,22 @@ function build_eepp( build_name ) filter "action:not vs*" cppdialect "C++14" + + filter "options:with-dynamic-freetype" + if not os.istarget("ios") and os_findlib("freetype") then + table.insert( link_list, get_backend_link_name( "freetype" ) ) + end end workspace "eepp" targetdir("./bin/") - configurations { "debug", "release" } - platforms { "x86_64", "x86" } + if os.istarget("ios") then + configurations { "debug-x64", "debug-arm64", "release-x64", "release-arm64" } + platforms { "x86_64", "arm64" } + else + configurations { "debug", "release" } + platforms { "x86_64", "x86" } + end rtti "On" download_and_extract_dependencies() select_backend() @@ -549,7 +553,10 @@ workspace "eepp" filter "platforms:x86" architecture "x86" - filter "platforms:x86_64" + filter "platforms:arm64 or configurations:debug-arm64 or configurations:release-arm64" + architecture "arm64" + + filter "platforms:x86_64 or configurations:debug-x64 or configurations:release-x64" architecture "x86_64" filter "system:macosx" @@ -560,10 +567,10 @@ workspace "eepp" ndkplatform "android-28" ndkstl "c++_static" - filter "configurations:debug" + filter "configurations:debug*" defines { "DEBUG" } symbols "On" - filter "configurations:release" + filter "configurations:release*" optimize "Speed" project "SOIL2-static" @@ -693,7 +700,7 @@ workspace "eepp" "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" } - filter "system:macosx" + filter "system:macosx or system:ios" excludes { "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", diff --git a/projects/ios/Info.plist b/projects/ios/Info.plist new file mode 100644 index 000000000..fbbaf7f93 --- /dev/null +++ b/projects/ios/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + + UILaunchStoryboardName + iOS Launch Screen + UISupportedInterfaceOrientations + + + diff --git a/projects/ios/Makefile b/projects/ios/Makefile deleted file mode 100644 index 5c3f8d5b7..000000000 --- a/projects/ios/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -IPHONE_IP:= -PROJECTNAME:=eepp -APPFOLDER:=$(PROJECTNAME).app -INSTALLFOLDER:=$(PROJECTNAME).app - -install: -ifeq ($(IPHONE_IP),) - echo "Please set IPHONE_IP" -else - ssh root@$(IPHONE_IP) 'rm -fr /Applications/$(INSTALLFOLDER)' - scp -r $(APPFOLDER) root@$(IPHONE_IP):/Applications/$(INSTALLFOLDER) - echo "Application $(INSTALLFOLDER) installed" - ssh mobile@$(IPHONE_IP) 'uicache' -endif - -uninstall: -ifeq ($(IPHONE_IP),) - echo "Please set IPHONE_IP" -else - ssh root@$(IPHONE_IP) 'rm -fr /Applications/$(INSTALLFOLDER)' - echo "Application $(INSTALLFOLDER) uninstalled" -endif - -.PHONY: install uninstall diff --git a/projects/ios/SDL2-sensors.patch b/projects/ios/SDL2-sensors.patch new file mode 100644 index 000000000..29a8d4e72 --- /dev/null +++ b/projects/ios/SDL2-sensors.patch @@ -0,0 +1,33 @@ +--- a/configure Mon Dec 30 17:56:56 2019 -0800 ++++ b/configure Tue Dec 31 10:40:30 2019 -0800 +@@ -25106,6 +25106,14 @@ + # have_haptic=yes + # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback" + #fi ++ # Set up files for the sensor library ++ if test x$enable_sensor = xyes; then ++ ++$as_echo "#define SDL_SENSOR_COREMOTION 1" >>confdefs.h ++ ++ SOURCES="$SOURCES $srcdir/src/sensor/coremotion/*.m" ++ have_sensor=yes ++ fi + # Set up files for the power library + if test x$enable_power = xyes; then + + +--- a/configure.ac Mon Dec 30 17:56:56 2019 -0800 ++++ b/configure.ac Tue Dec 31 10:40:30 2019 -0800 +@@ -3856,6 +3856,12 @@ + # have_haptic=yes + # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback" + #fi ++ # Set up files for the sensor library ++ if test x$enable_sensor = xyes; then ++ AC_DEFINE(SDL_SENSOR_COREMOTION, 1, [ ]) ++ SOURCES="$SOURCES $srcdir/src/sensor/coremotion/*.m" ++ have_sensor=yes ++ fi + # Set up files for the power library + if test x$enable_power = xyes; then + AC_DEFINE(SDL_POWER_UIKIT, 1, [ ]) diff --git a/projects/ios/compile-all.sh b/projects/ios/compile-all.sh index 511b92f4f..0783040bb 100755 --- a/projects/ios/compile-all.sh +++ b/projects/ios/compile-all.sh @@ -1,6 +1,15 @@ #!/bin/sh cd $(dirname "$0") +if [ ! -f ../../libs/ios/libSDL2.a ]; then + +cd ../../src/thirdparty/SDL2-2.0.10/build-scripts +./iosbuild.sh +cp lib/libSDL2.a ../../../../libs/ios/ +cd ../../../../projects/ios + +fi + ./compile-arm64.sh $@ ./compile-x86_64.sh $@ @@ -10,6 +19,6 @@ if [ -f arm64/libeepp-static-debug.a ] && [ -f x86_64/libeepp-static-debug.a ]; lipo -create -arch arm64 arm64/libeepp-static-debug.a -arch x86_64 x86_64/libeepp-static-debug.a -output ./libeepp-debug.a fi -if [ -f arm7/libeepp-static.a ] && [ -f x86/libeepp-static.a ]; then +if [ -f arm64/libeepp-static.a ] && [ -f x86_64/libeepp-static.a ]; then lipo -create -arch arm64 arm64/libeepp-static.a -arch x86_64 x86_64/libeepp-static.a -output ./libeepp.a fi diff --git a/projects/ios/compile-arm64.sh b/projects/ios/compile-arm64.sh index 55dc67830..0d7f61082 100755 --- a/projects/ios/compile-arm64.sh +++ b/projects/ios/compile-arm64.sh @@ -5,11 +5,11 @@ CLANGPATH=`xcrun -find -sdk iphoneos clang` export TOOLCHAINPATH=`dirname $CLANGPATH`/ if [ -z "$IOSVERSION" ]; then -export IOSVERSION=12.1 +export IOSVERSION=`xcrun --sdk iphoneos --show-sdk-version` fi if [ -z "$SYSROOTPATH" ]; then -export SYSROOTPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$IOSVERSION.sdk/ +export SYSROOTPATH=`xcrun --sdk iphoneos --show-sdk-platform-path`/Developer/SDKs/iPhoneOS$IOSVERSION.sdk/ fi premake4 --file=../../premake4.lua --platform=ios-arm64 --with-static-eepp --with-gles1 --with-gles2 --with-static-backend --use-frameworks gmake diff --git a/projects/ios/compile-x86.sh b/projects/ios/compile-x86.sh deleted file mode 100755 index c9f5588bd..000000000 --- a/projects/ios/compile-x86.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -cd $(dirname "$0") - -CLANGPATH=`xcrun -find -sdk iphoneos clang` -export TOOLCHAINPATH=`dirname $CLANGPATH`/ - -if [ -z "$IOSVERSION" ]; then -export IOSVERSION=10.0 -fi - -if [ -z "$SYSROOTPATH" ]; then -export SYSROOTPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$IOSVERSION.sdk/ -fi - -premake4 --file=../../premake4.lua --platform=ios-x86 --with-static-eepp --with-gles1 --with-gles2 --with-static-backend --use-frameworks gmake - -cd ../../make/ios-x86/ -make -j`nproc` $@ eepp-static diff --git a/projects/ios/compile-x86_64.sh b/projects/ios/compile-x86_64.sh index 760bf5644..58118ac0d 100755 --- a/projects/ios/compile-x86_64.sh +++ b/projects/ios/compile-x86_64.sh @@ -1,15 +1,15 @@ #!/bin/sh cd $(dirname "$0") -CLANGPATH=`xcrun -find -sdk iphoneos clang` +CLANGPATH=`xcrun -find -sdk iphonesimulator clang` export TOOLCHAINPATH=`dirname $CLANGPATH`/ if [ -z "$IOSVERSION" ]; then -export IOSVERSION=12.1 +export IOSVERSION=`xcrun --sdk iphonesimulator --show-sdk-version` fi if [ -z "$SYSROOTPATH" ]; then -export SYSROOTPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$IOSVERSION.sdk/ +export SYSROOTPATH=`xcrun --sdk iphonesimulator --show-sdk-platform-path`/Developer/SDKs/iPhoneSimulator$IOSVERSION.sdk/ fi premake4 --file=../../premake4.lua --platform=ios-x86_64 --with-static-eepp --with-gles1 --with-gles2 --with-static-backend --use-frameworks gmake diff --git a/projects/ios/cross-compile-arm7.sh b/projects/ios/cross-compile-arm7.sh deleted file mode 100755 index 08352d300..000000000 --- a/projects/ios/cross-compile-arm7.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -cd $(dirname "$0") - -premake4 --file=../../premake4.lua --platform=ios-cross-arm7 --with-static-eepp --with-gles1 --with-gles2 --with-static-backend gmake - -cd ../../make/ios-cross-arm7/ -make $@ diff --git a/projects/ios/cross-compile-x86.sh b/projects/ios/cross-compile-x86.sh deleted file mode 100755 index e993ace18..000000000 --- a/projects/ios/cross-compile-x86.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -cd $(dirname "$0") - -premake4 --file=../../premake4.lua --platform=ios-cross-x86 --with-static-eepp --with-gles1 --with-gles2 --with-static-backend gmake - -cd ../../make/ios-cross-x86/ -make $@ diff --git a/projects/ios/cross-install.sh b/projects/ios/cross-install.sh deleted file mode 100755 index aa90a5423..000000000 --- a/projects/ios/cross-install.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -ln -sf ../../../bin/assets ./eepp.app/ -echo "The fist parameter must be the path of the binary file to install. Example: ../../bin/eetest-debug.ios" -cp $1 ./eepp.app/eepp -make install $2 diff --git a/projects/ios/cross-uninstall.sh b/projects/ios/cross-uninstall.sh deleted file mode 100755 index eea209659..000000000 --- a/projects/ios/cross-uninstall.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -make uninstall diff --git a/projects/ios/eepp.app/Default.png b/projects/ios/eepp.app/Default.png deleted file mode 100644 index e0c6cde31..000000000 Binary files a/projects/ios/eepp.app/Default.png and /dev/null differ diff --git a/projects/ios/eepp.app/Default@2x.png b/projects/ios/eepp.app/Default@2x.png deleted file mode 100644 index 3a4886f69..000000000 Binary files a/projects/ios/eepp.app/Default@2x.png and /dev/null differ diff --git a/projects/ios/eepp.app/Icon-72.png b/projects/ios/eepp.app/Icon-72.png deleted file mode 100644 index fcfbc0ec3..000000000 Binary files a/projects/ios/eepp.app/Icon-72.png and /dev/null differ diff --git a/projects/ios/eepp.app/Icon.png b/projects/ios/eepp.app/Icon.png deleted file mode 100644 index a96d7a5cb..000000000 Binary files a/projects/ios/eepp.app/Icon.png and /dev/null differ diff --git a/projects/ios/eepp.app/Icon@2x.png b/projects/ios/eepp.app/Icon@2x.png deleted file mode 100644 index 39d5962d7..000000000 Binary files a/projects/ios/eepp.app/Icon@2x.png and /dev/null differ diff --git a/projects/ios/eepp.app/Info.plist b/projects/ios/eepp.app/Info.plist deleted file mode 100644 index 06db7d664..000000000 Binary files a/projects/ios/eepp.app/Info.plist and /dev/null differ diff --git a/projects/ios/eepp.app/README.txt b/projects/ios/eepp.app/README.txt deleted file mode 100644 index ae00c9894..000000000 --- a/projects/ios/eepp.app/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -iPhone App Icon: -Icon.png 57×57 App Store And iPhone、iPod touch Launcher Icon. (Needed) -Icon@2x.png 114×114 Retina mode of Icon.png. (Needed) -Icon-Small.png 29×29 Settings and Spotlight search icon. (Optional) -Icon-Small@2x.png 58×58 Retina mode of Icon-Small.png. (Optional) - -iPad App Icon: -Icon-72.png 72×72 iPad Launcher Icon. (Needed) -Icon-50.png 50×50 Spotlight search icon. (Optional) -Icon-29.png 29×29 Settings icon. (Optional) - -iPhone/iPad App Icon: -Icon.png 57×57 App Store And iPhone、iPod touch Launcher Icon. (Needed) -Icon-72.png 72×72 iPad Launcher Icon. (Needed) -Icon-50.png 50×50 iPad Spotlight search icon. (Optional) -Icon-29.png 29×29 Settings and iPhone Spotlight search icon. (Optional) - diff --git a/projects/ios/gen-xcode4-proj.sh b/projects/ios/gen-xcode4-proj.sh new file mode 100755 index 000000000..ede9451ab --- /dev/null +++ b/projects/ios/gen-xcode4-proj.sh @@ -0,0 +1,12 @@ +#!/bin/bash +premake5 --file=../../premake5.lua --os=ios --with-static-eepp --with-gles1 --with-gles2 --with-static-backend --use-frameworks xcode4 + +cp Info.plist ../../make/ios + +if [ ! -f ../../libs/ios/libSDL2.a ]; then + +cd ../../src/thirdparty/SDL2-2.0.10/build-scripts +./iosbuild.sh +cp lib/libSDL2.a ../../../../libs/ios/ + +fi diff --git a/src/eepp/window/backend/SDL2/displaymanagersdl2.cpp b/src/eepp/window/backend/SDL2/displaymanagersdl2.cpp index 47f2a348f..5d603de4c 100644 --- a/src/eepp/window/backend/SDL2/displaymanagersdl2.cpp +++ b/src/eepp/window/backend/SDL2/displaymanagersdl2.cpp @@ -24,11 +24,9 @@ Float DisplaySDL2::getDPI() { #if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN return 96.f * emscripten_get_device_pixel_ratio(); #else -#if SDL_VERSION_ATLEAST( 2, 0, 4 ) float ddpi, hdpi, vdpi; if ( 0 == SDL_GetDisplayDPI( 0, &ddpi, &hdpi, &vdpi ) ) return ddpi; -#endif return 96.f; #endif } @@ -83,11 +81,9 @@ DisplayMode DisplaySDL2::getClosestDisplayMode( DisplayMode wantedMode ) { } Rect DisplaySDL2::getUsableBounds() { -#if SDL_VERSION_ATLEAST( 2, 0, 5 ) SDL_Rect r; if ( SDL_GetDisplayUsableBounds( index, &r ) == 0 ) return Rect( r.x, r.y, r.w, r.h ); -#endif return Rect(); } diff --git a/src/eepp/window/backend/SDL2/inputsdl2.cpp b/src/eepp/window/backend/SDL2/inputsdl2.cpp index 7f9275528..a94d2a843 100644 --- a/src/eepp/window/backend/SDL2/inputsdl2.cpp +++ b/src/eepp/window/backend/SDL2/inputsdl2.cpp @@ -348,7 +348,6 @@ void InputSDL::injectMousePos( const Uint16& x, const Uint16& y ) { } Vector2i InputSDL::queryMousePos() { -#if SDL_VERSION_ATLEAST( 2, 0, 5 ) Vector2i mousePos; Vector2i tempMouse; Vector2i tempWinPos; @@ -361,11 +360,6 @@ Vector2i InputSDL::queryMousePos() { mousePos.x = (int)tempMouse.x - tempWinPos.x - bordersSize.Left; mousePos.y = (int)tempMouse.y - tempWinPos.y - bordersSize.Top; return mousePos; -#else - int x, y; - SDL_GetMouseState( &x, &y ); - return Vector2i( x, y ); -#endif } void InputSDL::init() { diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index 73255b9c4..b1a3f38d3 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -239,11 +239,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { mWindow.WindowConfig.Height = mWindow.DesktopResolution.getHeight(); } - mWindow.Flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; - -#if SDL_VERSION_ATLEAST( 2, 0, 1 ) - mWindow.Flags |= SDL_WINDOW_ALLOW_HIGHDPI; -#endif + mWindow.Flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI; if ( mWindow.WindowConfig.Style & WindowStyle::Resize ) { mWindow.Flags |= SDL_WINDOW_RESIZABLE; @@ -272,10 +268,6 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { mWindow.WindowConfig.Height *= mWindow.WindowConfig.PixelDensity; #endif -#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN - tmpFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI; -#endif - mSDLWindow = SDL_CreateWindow( mWindow.WindowConfig.Caption.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, mWindow.WindowConfig.Width, mWindow.WindowConfig.Height, tmpFlags ); @@ -288,27 +280,6 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { return false; } -// In some platforms it will not create the desired window size, so we query the real window size -// created -#if SDL_VERSION_ATLEAST( 2, 0, 1 ) - int w, h; - SDL_GL_GetDrawableSize( mSDLWindow, &w, &h ); - - if ( w > 0 && h > 0 ) { - mWindow.WindowConfig.Width = w; - mWindow.WindowConfig.Height = h; - mWindow.WindowSize = Sizei( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ); - } else { - eePRINTL( "Window failed to create!" ); - - if ( NULL != SDL_GetError() ) { - eePRINTL( "Error: %s", SDL_GetError() ); - } - - return false; - } -#endif - #if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS eePRINTL( "Choosing GL Version from: %d", Context.Version ); @@ -352,8 +323,8 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { if ( mWindow.ContextConfig.SharedGLContext ) { SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 ); - mGLContext = SDL_GL_CreateContext( mSDLWindow ); mGLContextThread = SDL_GL_CreateContext( mSDLWindow ); + mGLContext = SDL_GL_CreateContext( mSDLWindow ); } else { mGLContext = SDL_GL_CreateContext( mSDLWindow ); } @@ -374,6 +345,25 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { return false; } + // In some platforms it will not create the desired window size, so we query the real window + // size created + int w, h; + SDL_GL_GetDrawableSize( mSDLWindow, &w, &h ); + + if ( w > 0 && h > 0 ) { + mWindow.WindowConfig.Width = w; + mWindow.WindowConfig.Height = h; + mWindow.WindowSize = Sizei( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ); + } else { + eePRINTL( "Window failed to create!" ); + + if ( NULL != SDL_GetError() ) { + eePRINTL( "Error: %s", SDL_GetError() ); + } + + return false; + } + #if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN SDL_GL_SetSwapInterval( ( mWindow.ContextConfig.VSync ? 1 : 0 ) ); // VSync #endif @@ -770,26 +760,18 @@ const Sizei& WindowSDL::getDesktopResolution() { } Rect WindowSDL::getBorderSize() { -#if SDL_VERSION_ATLEAST( 2, 0, 5 ) Rect bordersSize; SDL_GetWindowBordersSize( mSDLWindow, &bordersSize.Top, &bordersSize.Left, &bordersSize.Bottom, &bordersSize.Right ); return bordersSize; -#else - return Rect(); -#endif } Float WindowSDL::getScale() { -#if SDL_VERSION_ATLEAST( 2, 0, 1 ) int realX, realY; int scaledX, scaledY; SDL_GL_GetDrawableSize( mSDLWindow, &realX, &realY ); SDL_GetWindowSize( mSDLWindow, &scaledX, &scaledY ); return (Float)realX / (Float)scaledX; -#else - return 1.f; -#endif } SDL_Window* WindowSDL::GetSDLWindow() const { diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index b12949132..383732676 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -558,7 +558,7 @@ void EETest::createBaseUI() { Menu->getItem( "Quit" )->addEventListener( Event::MouseUp, cb::Make1( this, &EETest::onQuitClick ) ); - SceneManager::instance()->getUISceneNode()->addEventListener( + SceneManager::instance()->getUISceneNode()->getRoot()->addEventListener( Event::MouseClick, cb::Make1( this, &EETest::onMainClick ) ); #ifdef EE_PLATFORM_TOUCH