Porting iOS and Android Games to BlackBerry 10

gamgutturalMobile - Wireless

Dec 10, 2013 (3 years and 6 months ago)


Porting iOS and Android Games to
BlackBerry 10
Sean Paul Taylor : Team Lead – Gaming R&D
May 14-16, 2013
 BlackBerry 10 Platform and Tools
 Cross-platform Development Practices
 Porting Sub-systems

iOS vs. Android vs. BlackBerry 10
BlackBerry 10
Platform and Tools
BlackBerry Platform
 Built on QNX Neutrino real-time OS
 Microkernel based
 POSIX compliant
 Native C/C++ applications
 Cellular, WiFi, Bluetooth and NFC
 Camera, Sensors and GPS
 Payment, Ads, Social
 Multimedia
 Messaging
 Security
BlackBerry Native SDK
 Supports Windows, MacOS X & Linux
 GCC based compiler tool chain
 GDB debugging
 Device deployment tools
 VMware simulator
 Eclipse CDT plug-in
 Visual Studio plug-in
 Debugging support
 Profiling and memory analysis support
Open Standards
 POSIX, STL, C++ and Sockets (libstdc++, libsockets)
 OpenGL ES 1.1 / 2.0 (libEGL, libGLESv1, libGLESv2)
 OpenAL 1.1 (libOpenAL)
 Imaging (libpng, libjpeg)
 Compression (libz, libbz2)
 Fonts (libfreetype)
 XML and Database
(libxml2, libxslt, libsqlite)
 Math (libm)
Open-source Support
 Boost (Utilities)
 Lua (Scripting)
 Box2D (2D Physics)
 Bullet (3D Physics)
 Recast (AI Pathfinding)
 Ogg / Vorbis (Compressed Audio)
 Cocos2D-X (2D Framework)

GamePlay 3D (3D Framework)

Development Practices
Game Engines and Frameworks
 Make use of cross-platform libraries if you can
 Platform related plumbing work already done such as:

Unity 3D engine

Shiva 3D engine

Marmalade SDK

Gameplay 3D framework

Cocos2D-X framework
Want to do it all yourself ? Consider a cross-platform design !
Why ?
1.Easy to port across platforms
2.Easy to maintain platform dependent code
How ?
1.Identify the platforms to support
Identify and isolate platform dependent & independent code

Cross-platform Design
Define cross-platform interfaces such as:
• touchEvent()
• showKeyboard(), hideKeyboard()
• getDPI()
Implement interfaces across the target platforms:
• PlatformBlackBerry.cpp
• PlatformiOS.mm


Isolate Platform Specifics
Game Code
Platform Implementations
Platform iOS
Platform BlackBerry
Platform Android
Sample Architecture
Programming Environments
 Objective-C based development
 Ability to mix C/C++
 Can easily be coded to support cross-platform

Android NDK
 Allows C/C++ implementation in Java application
 C/C++ code is run inside a Java process
 Not all APIs device features exposed in native
 Sometimes Java code must be called from native
 Primarily targeted at CPU-intensive applications
BlackBerry Native SDK
 Pure C/C++ environment
 Open standards compliant
 BlackBerry 10 apps are native processes
Development Tools
iOS – Xcode 4
 Xcode IDE
 Support for Objective-C and C/C++
 Integrated debugging + profiling
 Integrated simulator for all device form factors
 MacOS X only
Android NDK
 No direct Google driven NDK IDE support
 Some IDE plug-ins starting to show up (nVidia)
 Primarily command-line tools
 No profiling tools
 Stand-alone simulator
BlackBerry Native SDK
 Command-line tools (cross-platform)
 Eclipse CDT plugin (cross-platform)
 Visual Studio plugin (Windows only)
 Built-in profiling and debugging tools
 Simulator as a VMware Image
Porting Sub-systems
Main Entry Point
iOS – main()
Android – android_main()
BlackBerry – main()
Porting Sub-systems
iOS – Lifecycle
 Handled through the App Delegate
 Override methods to handle life cycle
 For example didFinishLaunchingWithOptions

iOS – Lifecycle
Android – Lifecycle
 Get android_app instance from the Native Activity
 Register callback function to the android_app
 Poll eventQueue for application lifecycle events

Android – Lifecycle
BlackBerry – Lifecycle
 BlackBerry Platform Service (BPS)

Navigator / Lifecycle


 Initialize the BPS system
 Request for specific system events
 Poll for events in loop
 Shutdown BPS system before exit

BlackBerry – Lifecycle
Porting Sub-systems
iOS – Input
Android – Input
BlackBerry – Input
Porting Subsystems
Graphics and Windowing
iOS – Graphics and Windowing
 OpenGL ES and EGL supported
 UIWindow is created in the App Delegate
 UIView class presents a drawable context
 EAGLView wraps OpenGL context

iOS – Graphics and Windowing
Android – Graphics and Windowing
 OpenGL ES and EGL supported
 Native Window created with default settings by App
 Can be obtained from android_app handle
 Choose the native window format using

Android – Graphics and Windowing
BlackBerry – Graphics and Windowing
 BPS to access to the Windowing system
 It allows creation of screen contexts
 Screen Context represents a connection to windowing
server and allows creation of screen windows
 EGL API glues the screen window and the OpenGL ES
rendering code

BlackBerry – Graphics and Windowing
Porting Sub-systems
File I/O
iOS – File I/O
 Application run in a sandbox
 Data stored in the App Directory
 Similar to BlackBerry
Android – File I/O
 Internal and external (removable/mountable)
 Data paths are obtained from below mentioned
variable available in the native_activity.h

BlackBerry – File I/O
 Use getcwd() for sandbox path
 Other useful paths:

App data: /app/native/

App memory: /accounts/1000/appdata/unique-app-name

Shared memory: /accounts/1000/shared

Porting Sub-systems
iOS – Audio
 OpenAL supported out of the box

Proprietary audio compression supported
 iOS provides proprietary Audio APIs with compressed
audio support through

AV Foundation

Audio Toolbox

Android – Audio
 No platform level audio API supported
 Android SDK supports OpenSL ES
 No out-of-the-box platform support for OpenAL
 Easy to port OpenSL ES to OpenAL
 Easiest to use open-source OpenAL implementation:

BlackBerry Native SDK
 Full support for OpenAL 1.1
 Low-level audio operations supported through
libasound, very similar to ALSA
 Ogg Vorbis + OpenAL can reduce memory

Blog and sample can be found here:

Porting Sub-systems
iOS – Video
 AV Player can be used to play videos
 Supports local and remote videos

Android – Video
 No native platform support for playing videos
 Can mangle JNI interfaces to use Java API’s
 Games can use open-source libraries

ffmpeg, theora, etc for native video support

• No platform level native support for payment APIs
• Application needs to call Java Payment API from native

Payment services directly available through BPS

• StoreKit framework for in-app payments
• App can embed App Store payment processing
In-App Purchasing
Scoreloop Social SDK
 User profile
 Leaderboards
 Achievements
 Challenges
 Multi-platform solution


Questions ?

BlackBerry® Z10 smartphone

Sean Paul Taylor
Team Lead – Gaming R&D


Sean Paul Taylor : Team Lead – Gaming R&D
May 14-16, 2013