Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. Orion Granatir & Omar Rodriguez GDC 2013 www.intel.com/software/gdc Be Bold. Define the Future of Software.
Agenda Understand the major mobile platforms 5 steps to being truly cross-platform How to {sup}port Android, Windows, ios Examples with Mortar and Marmalade 2
Step 0 Use a game engine 3
Step 1 Abstract hardware/os 1. Abstract the GPU with OpenGL 2. Abstract the CPU by using standard C/C++ 3. Any architecture specific code (ASM, SIMD, etc) will have to be rewritten 4
Step 2 Unified code base 1. C/C++ is the most portable language!! 2. Use multiple files instead of a ton of #defines 3. Define common OS functionality in a common header: system_android.c system_windows.c file.h system_ios.m 5
Step 3 Build from one place and in one way 1. Most developers build from Visual Studio (works with everything except ios). 2. There are lots of options to emulate OpenGL ES on Windows. You can implement most major functionality in an environment with a good debugger. 6
Step 4 Plan ahead for multiple screen sizes/resolutions 1. Multiple screen dimensions and resolutions are a problem on all platforms (including ios!), so plan ahead. 2. Scale with OpenGL (the UI needs the most work). 3. Consider Dynamic Resolution Scaling 7
Dynamic Resolution Scaling http://software.intel.com/en-us/android
Step 5 Use the right tools 1. There are no good completely cross platform tools. They are generally hardware specific. 2. Use Intel Graphics Performance Analyzer and Intel VTune Amplifier for Intel hardware 9
Profile: Intel Graphics Performance Analyzer 1. Install APK 2. On dev machine, run System Analyzer 3. Profile Come see this at the Intel booth!! 10
{Sup}port Android 1. Let the NDK do the hard work. Write minimal JNI wrapper. 2. Add multiple ABIs in Application.mk file (ARMv5, ARMv7, x86). Build ARM v5 Build ARM v7a Build x86 11
Test on HAXM emulator 1. Download the HAXM emulator from the Android SDK Manager 12
Test on HAXM emulator 2. Create a new virtual device with x86 as the target. The emulator will run with hardware acceleration. 13
{Sup}port ios 1. Objective-C works well with C/C++. Isolate Objective-C code and call into from standard C/C++. 2. ios has a good debugger, use it! 14
{Sup}port Windows 1. Treat Desktop and Metro (aka Windows 8 Store apps) as separate platforms. 2. It s easy to add touch to the Desktop (with the latest APIs). 15
Mortar Engine by Halfbrick
Example: Fruit Ninja A game that runs everywhere 15+ Platforms supported: ios Android Windows Desktop (XP/Win7) -- Primary Development Platform. Windows 8 Metro Windows Phone Xbox 360 Flash HTML 5 Symbian^3 Bada Coin op-arcade Linux Smart TVs OS X Several more! We want to be everywhere! Courtesy of Richard McKinney, Halfbrick CTO 17
Mortar Engine Rendering API (360, D3D9, GLES1, GLES2, D3D11, etc) Abstractions around Meshes, Vertex Buffers, Index Buffers, Effects, Shaders, Textures, etc.. Pretty much every API has these concepts which we can abstract per API. Sound/Music API (OpenAL, OpenSL, Java, XAudio2, Xact, etc) We don t get too complicated with sound in our games, so we re able to easily provide abstracted sound handles to games that don t know the underlying API. We ve actually recently moved towards a software mixer implementation on most platforms due to the extreme fragmentation within different implementations of the same API by multiple vendors (Android!) 2012 Halfbrick Studios Pty Ltd. 18
Mortar Engine Input API (DirectInput, Metro, ios, Android, etc): This is always specific to the platform. You will notice that the Touch and Mouse support in Metro is extremely similar to ios. We have generic Touch classes that encapsulate the multiple touches you can subscribe to. Smaller Items: FileIO: Sometimes just CRT, sometimes optimal beyond that. Networking and HTTP communications: Most games need to phone home. Social Networking APIs (Facebook and Twitter -> Share Contracts). IAP/Microtransaction systems (Windows Store, Google Play, itunes). Cloud Services: We have rolled our own solution, but platform based solutions do exist. 2012 Halfbrick Studios Pty Ltd. 19
Mortar Engine That can t be all?! Of course not. BUT, most everything else is cross platform C++ code that works between ALL of our deployment platforms. Avoid platform implementations for things you can do in a cross platform way: Collision Math UI Serialization Event Handling True Type Fonts Much, much more truly cross platform C++ code. 2012 Halfbrick Studios Pty Ltd. 20
Marmalade Tim Closs, CTO 28-Mar-13 21
28-Mar-13 2012 Marmalade. Trademarks belong to their respective owners. All rights reserved. 22
What is the Marmalade SDK? Marmalade SDK is a powerful cross-platform SDK for the efficient development of richer games and apps for mobile, desktop and Smart TV platforms. Marmalade is highly CROSS-PLATFORM Marmalade is also FAST, FLEXIBLE and OPEN
Cross-platform From a single codebase, create native games and apps entirely in Windows / Visual Studio or on Mac / Xcode and deploy to: ios (3.0+) Android (2.3+) NOW x86! BlackBerry 10 (+ PlayBook OS) Windows Phone 8 Windows (7, Vista, XP3) Mac OS X (10.6+) LG Smart TV Coming next Windows Store Roku
Fast Marmalade enables direct access to the hardware, providing native performance on every device Compile natively for the CPU Maximum CPU performance (not limited by virtual machines) Target OpenGL ES directly Maximum GPU performance 28-Mar-13 2012 Marmalade. Trademarks belong to their respective owners. All rights reserved. 25
Flexible and Open
Develop entirely on Windows or Mac
Case Studies PES 2010, 2011, 2012 (Konami) Cut the Rope (ZeptoLab)
Marmalade Quick: Rapid 2D game dev Build 2D games quickly. No need to use C++ Open source and extendable if needed Write in Lua, the fastest scripting language around 2D graphics, animation, fonts, vector shapes, particles, scene transitions, physics, audio, databases, web views, networking, Facebook, ads, analytics, cross-platform billing API Uses popular frameworks Cocos2d, Box2D, etc Integrated with free ZeroBrane IDE FREE with all Marmalade licence types
Marmalade Quick: Case study Flagship game built by Marmalade Game Studio Helped shape Marmalade Quick Super-smooth puzzle game Lots of great visual effects Released simultaneously on App Store, Google Play, Amazon Appstore, BlackBerry World Uses cross-platform billing API
Marmalade Juice Marmalade Juice removes brute-force porting from ios Keep using Xcode, Objective-C & ios APIs, for all platforms Port from ios to Android without changing how you work Target all platforms from a single codebase A single codebase means app updates are easier and cheaper Only minor modifications needed so you can focus on optimisation An Open Source add-on edit improve/change as you like
Case Study: Tap Paradise Cove Top-10 Grossing ios game Ported to Android using Marmalade Juice Launched on Google Play and Amazon Appstore Reached over 1m new users Now looking to target ios/android from single Objective-C codebase
Richer apps are www.madewithmarmalade.com
Conclusions Follow the 5 easy steps to build a truly cross platform game. Intel has a lot of tools and resources to help. Please contact us! 34
The Next Session 4:00 p.m. to 5:00 p.m. OpenCL Apply Parallel Compute Capabilities to 2D/3D Scenes Presenters: Michał Mrozek and Krzysztof Laskowski For more information: www.intel.com/software/gdc GDC 2013 35
The Next Session 5:30 p.m. to 6:30 p.m. Why Render Hidden Objects? Cull Them with a Software Depth-buffer Rasterizer! Presenter: Charumathi Chandrasekaran For more information: www.intel.com/software/gdc GDC 2013 36
Legal Disclaimers INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY RELATING TO SALE AND/OR USE OF INTEL PRODUCTS, INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT, OR OTHER INTELLECTUAL PROPERTY RIGHT. Intel products are not intended for use in medical, life saving, life sustaining, critical control or safety systems, or in nuclear facility applications. Intel Corporation may have patents or pending patent applications, trademarks, copyrights, or other intellectual property rights that relate to the presented subject matter. The furnishing of documents and other materials and information does not provide any license, express or implied, by estoppel or otherwise, to any such patents, trademarks, copyrights, or other intellectual property rights. Intel may make changes to specifications, product descriptions, and plans at any time, without notice. The Intel processor and/or chipset products referenced in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request. All dates provided are subject to change without notice. All dates specified are target dates, are provided for planning purposes only and are subject to change. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. * Other names and brands may be claimed as the property of others. Copyright 2012, Intel Corporation. All rights reserved. GDC 2013 37
GDC 2013 38