development of cross-platform mobile game technology

44
Development of cross-platform mobile game technology Benjamin J. Block Cute Attack, Oy Shared Gems 2013

Upload: benjamin-block

Post on 29-Nov-2014

982 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Development of cross-platform mobile game technology

Development of cross-platform mobile

game technologyBenjamin J. BlockCute Attack, Oy

Shared Gems 2013

Page 2: Development of cross-platform mobile game technology
Page 3: Development of cross-platform mobile game technology
Page 4: Development of cross-platform mobile game technology

PhD in Computational PhysicsUniversity of Mainz

Mobile Games Technology

Page 5: Development of cross-platform mobile game technology
Page 6: Development of cross-platform mobile game technology

Background

Software Engineering in Games is HARDArchitecture is most important challenge

Why?● High performance constraint

● High complexity and interconnectivity

→ Can reusable and modular software design be achieved while maintaining high performance?

Page 7: Development of cross-platform mobile game technology

Why no middleware?

● No control over development

● Performance penalties

● I wanted to learn something

● It's more fun

Page 8: Development of cross-platform mobile game technology

Target platforms

=

(c) Rareware

Page 9: Development of cross-platform mobile game technology

Target platforms

=

Page 10: Development of cross-platform mobile game technology

Target platforms

Page 11: Development of cross-platform mobile game technology

Platform independence

● Write as much as possible in a standard/portable language

Obj-C

C++Platform independent code

Platform specific code

iOS Android

JavaJNI

Page 12: Development of cross-platform mobile game technology

Platform independence?

● Easy transition to any platform that supports C++

+

Page 13: Development of cross-platform mobile game technology

Entity System (the glue and

communication channel)

System

Physics

Renderer (Graphics)

Tools

Input

Game Code

Sound

Resource Management

ThreadsFile I/O

Scene

Architecture Overview

Page 14: Development of cross-platform mobile game technology

Engine SubsystemsWalkthrough

Page 15: Development of cross-platform mobile game technology

Input

ThreadsFile I/OSystem

● Initialize Subsystems

● Provide a callback that is called each frame

● Provides threads for asynchronous tasks

● Invoke certain device specific actions (e.g.: Post to facebook, show onscreen keyboard, In-App purchases)

● Input: Touch handling, Keystrokes (Android: Back button), Other platforms (Keybaord, Mouse)

● Read and write files (resources, save games)

Main platform dependent part

Page 16: Development of cross-platform mobile game technology

Entity System

Scene

Entities (Game Objects)

Collection of components

Page 17: Development of cross-platform mobile game technology

Entity System

SceneComponent

Properties

Entities (Game Objects)

Page 18: Development of cross-platform mobile game technology

Entity System

● Component properties can be saved to and loaded from storage

● Properties can be read and modified by runtime systems (physics, game code, renderer, etc)

● Fast queries of the type: Return all objects that have a certain component

e.g. render all meshes, rotate all cannons, etc

Page 19: Development of cross-platform mobile game technology

Resource Handling

TexturesSound Files

Geometry

Page 20: Development of cross-platform mobile game technology

● Decompression is fast compared to reading data from storage

● Extract resources on-demand from ZIP

● Retrieving a resource still takes time, and we need a robust system to handle this latency

Resource Streaming

Page 21: Development of cross-platform mobile game technology

Renderer

Time

Draw, Draw

Page 22: Development of cross-platform mobile game technology

RendererDraw, Draw

?

Page 23: Development of cross-platform mobile game technology

Renderer

Resource Streaming

RequestTexture

Draw, Draw

Page 24: Development of cross-platform mobile game technology

Renderer

Resource Streaming

RequestTexture

Continue, ignoring texture until it is loadedDraw, Draw

Time

Page 25: Development of cross-platform mobile game technology

Renderer

Resource Streaming

System

RequestTexture

Read from storage *.zip, unpack

Requestdata

Draw, Draw

Time

Page 26: Development of cross-platform mobile game technology

Renderer

Resource Streaming

System

RequestTexture

Decode, upload to GPU

Read from storage *.zip, unpack

Requestdata

Draw, Draw

Time

Page 27: Development of cross-platform mobile game technology

Renderer

Resource Streaming

System

RequestTexture

Decode, upload to GPU

Read from storage *.zip, unpack

Requestdata

Return Texture Handle

Draw, Draw

Time

Page 28: Development of cross-platform mobile game technology

Renderer

Resource Streaming

System

RequestTexture

Decode, upload to GPU

Read from storage *.zip, unpack

Requestdata

Return Texture Handle

Draw with actual texture

Draw, Draw

Time

Page 29: Development of cross-platform mobile game technology

Sound

Small files, fit in memoryLarge files, need to be streamedAnd compressed

~40 MB for a file< 0.5 MB for a file

One Shot Background Music

Page 30: Development of cross-platform mobile game technology

Audio Compression

?

Page 31: Development of cross-platform mobile game technology

Audio Compression

Page 32: Development of cross-platform mobile game technology

● 4:1 compression ratio

● decoded in about 100 lines of code

● runs on any platform

Audio Compression

AIFC/IMA4Lightweight solution?

Page 33: Development of cross-platform mobile game technology

Sound on Android

● Historically THE weakness of the Android platform

● iOS: OpenAL, established industry standard

Page 34: Development of cross-platform mobile game technology

Sound on Android

● Historically THE weakness of the Android platform

● iOS: OpenAL, established industry standard

● Android < 2.3: Java-only API

- Not easy to access from C++

- High latency on some devices

- More problematic than GPU fragmentation

Page 35: Development of cross-platform mobile game technology

Sound on Android

● Historically THE weakness of the Android platform

● iOS: OpenAL, established industry standard

● Android < 2.3: Java-only API

- Not easy to access from C++

- High latency on some devices

- More problematic than GPU fragmentation

● Android >= 2.3: OpenSL ES

Page 36: Development of cross-platform mobile game technology

GraphicsSpeaking of GPU fragmentation...

Page 37: Development of cross-platform mobile game technology

GraphicsSpeaking of GPU fragmentation...

Page 38: Development of cross-platform mobile game technology

Graphics

● OpenGL ES 1.1 with fixed function pipeline

(support for early iPhones and some low cost android phones)

● OpenGL ES 2.0 with shader generator & shader cache

(for current and future devices)

Speaking of GPU fragmentation...

Page 39: Development of cross-platform mobile game technology

Textures

● Store textures in a native format, to avoid long loading times (NO PNG!)

● Consider using 16 bit formats instead of 32 bit

● Do not use alpha channel if not needed

● Consider using Texture Compression if you can control the artefacts (alpha!)

Page 40: Development of cross-platform mobile game technology

Texture Compression

● Many different compression standards

● On iOS there is only one brand of GPU (PowerVR) and all support PVRTC.

● Android: Trouble, at least 3 major different formats, some devices do not support any compression

● If you can avoid it, perfect (we avoided it on Android, but we use PVRTC on iOS)

● Retina/Hi-Res Screens might force you to use some form of compression (2048x2048 Texture = 16 MB!!)

Page 41: Development of cross-platform mobile game technology

5 Physics

p

Page 42: Development of cross-platform mobile game technology

Physics

● 2D physics

● Sequential Impulse approach for collision response

● For everyone interested – check out the GDC 2009 slides by Erin Catto (Box2D) they should get you started.

● Custom solution – very simple, but I wanted to get to the bottom of it

Page 43: Development of cross-platform mobile game technology

Lessons learned

● It works! (→ Captain Clumsy)

● Platform abstraction is worth the effort

● Custom technology is feasible, even fora small team

● Technology can be reused for next games

● Spend more time on tools

Page 44: Development of cross-platform mobile game technology

Get in touch

● Email me at: [email protected]

● Twitter: lhyanor

● Cute Attack Website: cuteattack.com

Thank you for your attention :)