Merge: Gamnit on iOS
authorJean Privat <jean@pryen.org>
Thu, 25 Jan 2018 20:16:37 +0000 (15:16 -0500)
committerJean Privat <jean@pryen.org>
Thu, 25 Jan 2018 20:16:37 +0000 (15:16 -0500)
commita59e09668c0ed1f9ead39acb8a25e3840f3135a0
treecb731db5f924c8ef8f7602940e3b3edd5939ce57
parent0b0fc2a2959acaa0b4bf46148085ea635df2418b
parent04b111d4693bdef50e1187ed1538dc0774860e36
Merge: Gamnit on iOS

Support iOS as a target for Gamnit games, including:

* GC on iOS and Xcode assets folder support in the compiler.
* iOS view controller and OpenGL view using the GLKit services.
* Loading of assets: sound, texture and text (and thus 3D models and fonts).
* iOS touch event and orientation change support.
* A few bug fix and tweaks to Gamnit.
* Minimal makefile rules to target iOS.

The game `asteronits` works as expected, here it is on iPad (With controls that are way too big):

![screen shot 2018-01-14 at 10 11 17](https://user-images.githubusercontent.com/208057/34918201-187b8b4a-f91d-11e7-86a2-6b891b237316.png)

Limitations:
* By default, the compiler generates an app for the simulator. To compile for a physical device, in practice, I run `nitc -m ios --compile-dir nit_compile` to generate the iOS project and view errors in Nit or in the custom Objective-C code. And then I launch Xcode with `open -a xcode nit_compile/ios/my_project.xcodeproj` to compile and run on a device from there.

* The depth API (3D) does not work on iOS with this PR because of known bugs in the current implementation. I have a rewrite of the depth API that fixes these bugs and bring a much needed performance boost.

* A `Sound` instance can't be played more than once concurrently. This could be improved by using `AVPlayer` as kind of sound channel and an `AVPlayerItem` for each sound instance, instead of the current `AVAudioPlayer`.

* iOS does not support exactly the same format for assets than Android. Sounds in mp3 format should work on both platforms. PNG files work on both platforms but iOS is more picky on the color palette, I've had an issue with a greyscale PNG, RGBA PNG files should be safe.

  You can always use the `app_files` annotation to include platform-specific assets.

* `gamnit::selection` does not work on iOS because we can't read the screen pixels. It should be updated to use an FBO.

* We still need a portable API for locking the screen orientation.

* Compiling Gamnit games for iOS fails at a missing pkg-config package. The package is not used and in can be safely ignored by removing the "pkgconfig" line in `lib/glesv2/glesv2.nit`. I'll need to find a clean fix for this...

Pull-Request: #2605
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
lib/gamnit/gamnit.nit
lib/glesv2/glesv2.nit
tests/Darwin.skip