cross-platform game development - intel · cross-platform game development best practices learned...

38
www.intel.com/software/gdc www.intel.com/software/gdc Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. Orion Granatir & Omar Rodriguez www.intel.com/software/gdc Be Bold. Define the Future of Software. GDC 2013

Upload: others

Post on 11-Apr-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

www.intel.com/software/gdc www.intel.com/software/gdc

Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc.

Orion Granatir & Omar Rodriguez

www.intel.com/software/gdc Be Bold. Define the Future of Software. GDC 2013

Page 2: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 3: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Step 0 – Use a game engine

3

Page 4: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 5: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

system_iOS.m file.h 5

Page 6: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 7: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 8: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Dynamic Resolution Scaling

• http://software.intel.com/en-us/android

Page 9: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 10: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 11: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

{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

Page 12: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Test on HAXM emulator

1. Download the HAXM emulator from the Android SDK Manager

12

Page 13: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Test on HAXM emulator

2. Create a new virtual device with x86 as the target.

The emulator will run with hardware acceleration.

13

Page 14: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

{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

Page 15: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

{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

Page 16: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Mortar Engine by Halfbrick

Page 17: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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!

17

Courtesy of Richard McKinney, Halfbrick CTO

Page 18: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Mortar Engine 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

Page 19: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Mortar Engine 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

Page 20: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Mortar Engine Mortar Engine

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.

That can’t be all?!

20

Page 21: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Marmalade

21 28-Mar-13

Tim Closs, CTO

Page 22: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

28-Mar-13 ©2012 Marmalade. Trademarks belong to their respective owners. All rights reserved. 22

Page 23: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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 also FAST, FLEXIBLE and OPEN Marmalade is also FAST, FLEXIBLE and OPEN

Marmalade is highly CROSS-PLATFORM Marmalade is highly CROSS-PLATFORM

Page 24: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Cross-platform

• 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

• 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

Coming next • Windows Store • Roku

From a single codebase, create native games and apps entirely in Windows / Visual Studio or on Mac / Xcode and deploy to:

Page 25: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 27: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Develop entirely on Windows or Mac

Page 28: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Case Studies

PES 2010, 2011, 2012 (Konami)

Cut the Rope (ZeptoLab)

Page 29: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 30: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 31: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 32: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 33: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

Richer apps are

www.madewithmarmalade.com

Page 34: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 35: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 36: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 37: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

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

Page 38: Cross-Platform Game Development - Intel · Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc. ... (Facebook and Twitter -> Share Contracts)

GDC 2013

38