Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Android NDK Game Development Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Android NDK Game Development Cookbook

Android NDK Game Development Cookbook

By : Sergey Kosarevsky, Viktor Latypov
4 (5)
close
close
Android NDK Game Development Cookbook

Android NDK Game Development Cookbook

4 (5)
By: Sergey Kosarevsky, Viktor Latypov

Overview of this book

Android NDK is used for multimedia applications which require direct access to a system's resources. Android NDK is also the key for portability, which in turn provides a reasonably comfortable development and debugging process using familiar tools such as GCC and Clang toolchains. If your wish to build Android games using this amazing framework, then this book is a must-have.This book provides you with a number of clear step-by-step recipes which will help you to start developing mobile games with Android NDK and boost your productivity debugging them on your computer. This book will also provide you with new ways of working as well as some useful tips and tricks that will demonstrably increase your development speed and efficiency.This book will take you through a number of easy-to-follow recipes that will help you to take advantage of the Android NDK as well as some popular C++ libraries. It presents Android application development in C++ and shows you how to create a complete gaming application. You will learn how to write portable multithreaded C++ code, use HTTP networking, play audio files, use OpenGL ES, to render high-quality text, and how to recognize user gestures on multi-touch devices. If you want to leverage your C++ skills in mobile development and add performance to your Android applications, then this is the book for you.
Table of Contents (11 chapters)
close
close
10
Index

Preface

Mobility and the demand for high-performance computations are often very tightly coupled. Current mobile applications do many computationally-intense operations such as 3D and stereoscopic rendering, images and audio recognition, and video decoding and encoding, especially the birth of new technologies such as the augmented reality. This include mobile games, 3D user interface software, and social software, which involves media stream processing.

In some sense, mobile game development forces us to travel back in time several years due to the limited hardware capabilities, low memory bandwidth, and precious battery resources, but also makes us reconsider the basic forms of interaction with the user.

A smooth and responsive user interface based on gesture input, Internet access, ambient sound effects, high-quality text, and graphics are the ingredients of a successful mobile application.

All major mobile operating systems give software developers different possibilities to develop close-to-the-hardware. Google provides an Android Native Development Kit (NDK) to ease the porting of existing applications and libraries from other platforms to Android, and exploit the performance of the underlying hardware offered by the modern mobile devices. C, and especially C++, both have a reputation of being a hard language to learn, and a hard language to write user interface code in. This is indeed true, but only when someone attempts to write everything from scratch. In this book we use C and C++ programming languages, and link them to well-established third-party libraries to allow the creation of content-rich applications with a modern touch-based interface and access to the Representational State Transfer (REST) APIs of popular sites such as Facebook, Twitter, Flickr, Picasa, Instagram, and a myriad of others.

Despite the availability of the information on how to use Internet resources in the applications written in Java or .NET languages, not much has been said about doing this in C++ programming language. Modern OpenGL versions require a sufficient amount of effort to create and use the latest extensions. The programming using the OpenGL API is usually described in literature in a platform-specific way. Things get even more complicated with the mobile version, the OpenGL ES, as developers have to adapt existing shader programs to allow them to run on the mobile graphics processing units (GPUs). Sound playback using standard Android facilities in C++ is also not straightforward, for example, things should be done to re-use the existing PC code for the OpenAL library. This book tries to shed some light on these topics and combine a number of useful recipes to simplify the multiplatform-friendly development with Android NDK.

Android is a mobile operating system based on the Linux kernel and designed for smartphones, tablet computers, netbooks, and other portable devices. Initial development of Android was started by Android Inc, which was bought by Google in 2005. In November 2007, the first version was unveiled, however, the first commercially available Android-based smartphone, HTC Dream, was released almost one year later in 2008.

Android versions, besides a numerical denomination, have official code names—each major release is named after a sweet dessert. The following are some significant milestones in Android platform technologies and features related to NDK:

  • Version 1.5 (Cupcake): This Android version featured the first release of Android Native Development Kit supporting ARMv5TE instructions.
  • Version 1.6 (Donut): First introduction of OpenGL ES 1.1 native library support.
  • Version 2.0 (Eclair): OpenGL ES 2.0 native library support.
  • Version 2.3 (Gingerbread):
    • Concurrent garbage collector in Dalvik VM. This has faster gaming performance and improved efficiency of OpenGL ES operations.
    • Capabilities of Native Development Kit are greatly extended, including sensors access, native audio OpenSL ES, the EGL library, activity life cycle management, and native access to assets.
  • Version 3.0 (Honeycomb):
    • Support for tablet computers with large touch screens
    • Support of multicore processors
  • Version 4.0 (Ice Cream Sandwich):
    • Unified UI for smartphones and tablet
    • Hardware-accelerated 2D rendering. VPN client API
  • Versions 4.1 and 4.2 (Jelly Bean):
    • This has improved rendering performance and triple buffering
    • External display support, including external displays over Wi-Fi
    • They have high-dynamic range camera support
    • New built-in developer options for debugging and profiling. Dalvik VM runtime optimizations
  • Version 4.3 (Jelly Bean): OpenGL ES 3.0 native library support.
  • Version 4.4 (KitKat): Introduced access to RenderScript from NDK. This feature is backwards compatible with any device running Android 2.2 or higher.

Android Native Development Kit (NDK) is used for multimedia applications that require performance that Dalvik is unable to provide, and direct access to the native system libraries. NDK is also the key for portability, which in turn allows a reasonably comfortable development and debugging process using familiar tools such as GCC and Clang toolchains or alike. The typical usage of NDK determines the scope of this book—integration of some of the most commonly used C/C++ libraries for graphics, sound, networking, and resource storage.

Initially, NDK was based on the Bionic library. It is a derivation of the BSD standard C library (libc) developed by Google for Android. The main goals of Bionic were as follows:

  • License: Original GNU C Library (glibc) is GPL-licensed and Bionic has a BSD license.
  • Size: Bionic is much smaller in size compared to GNU C Library.
  • Speed: Bionic is designed for mobile CPUs with relatively low clock frequencies. For example, it has a custom implementation of pthreads.

Bionic lacks many important features found in full libc implementations, such as RTTI and C++ exceptions handling support. However, NDK provides several libraries with different C++ helper runtimes which implement these features. These are GAbi++ runtime, STLport runtime, and GNU Standard C++ Library. Besides the basic POSIX features, Bionic has support for Android-specific mechanisms such as logging.

The NDK is a very effective way to reuse a great body of existing C and C++ code.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Android NDK Game Development Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon