You are previewing Android NDK Game Development Cookbook.
O'Reilly logo
Android NDK Game Development Cookbook

Book Description

For C++ developers, this is the book that can swiftly propel you into the potentially profitable world of Android games. The 70+ step-by-step recipes using Android NDK will give you the wide-ranging knowledge you need.

  • Tips and tricks for developing and debugging mobile games on your desktop

  • Enhance your applications by writing multithreaded code for audio playback, network access, and asynchronous resource loading

  • Enhance your game development skills by using modern OpenGL ES and develop applications without using an IDE

  • Features two ready-to-run Android games

  • In Detail

    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

    1. Android NDK Game Development Cookbook
      1. Table of Contents
      2. Android NDK Game Development Cookbook
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who is this book for
        4. Building the source code
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code for this book
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Establishing a Build Environment
        1. Introduction
        2. Installing Android development tools on Windows
          1. Getting ready
          2. How to do it...
          3. There's more...
        3. Installing Android development tools on Linux
          1. Getting ready
          2. How to do it...
          3. There's more...
        4. Creating an application template manually
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also…
        5. Adding native C++ code to your application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Switching NDK toolchains
          1. Getting ready
          2. How to do it...
          3. There's more...
        7. Supporting multiple CPU architectures
          1. Getting ready
          2. How to do it...
          3. There's more...
        8. Basic rendering with OpenGL ES
          1. Getting ready
          2. How to do it…
          3. How it works…
        9. Going cross platform
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
          5. See also
        10. Unifying the cross-platform code
          1. Getting ready
          2. How to do it...
          3. There's more...
        11. Linking and source code organization
          1. Getting ready
          2. How to do it...
          3. How it works...
        12. Signing release Android applications
          1. Getting ready
          2. How to do it...
          3. See also
      9. 2. Porting Common Libraries
        1. Introduction
        2. Compiling the native static libraries for Windows
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There’s more...
        3. Compiling the native static libraries for Android
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Compiling the libcurl networking library
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There’s more…
          5. See also
        5. Compiling the OpenAL library
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. See also
        6. Compiling libvorbis, libmodplug, and libtheora
          1. Getting ready
          2. How to do it...
        7. Using the FreeImage graphics library
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There’s more…
          5. See also
        8. Using the FreeType library for text rendering
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There’s more...
        9. Implementing timing in physics
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also…
        10. Rendering graphics in 2D
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also …
        11. Setting up Box2D simulations
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There’s more...
          5. See also
        12. Building the ODE physical library
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There’s more...
          5. See also
      10. 3. Networking
        1. Introduction
        2. Fetching list of photos from Flickr and Picasa
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Downloading images from Flickr and Picasa
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Performing cross-platform multithreading
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Synchronizing native cross-platform threads
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Managing memory using reference counting
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Implementing asynchronous task queues
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Handling asynchronous callbacks invocation
          1. Getting ready
          2. How to do it…
          3. How it works…
        9. Working with the network asynchronously
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        10. Detecting a network address
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        11. Writing the HTTP server
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      11. 4. Organizing a Virtual Filesystem
        1. Introduction
        2. Abstracting file streams
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Implementing portable memory-mapped files
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Implementing file writers
          1. How to do it...
          2. How it works…
          3. See also
        5. Working with in-memory files
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Implementing mount points
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Enumerating files in the .zip archives
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Decompressing files from the .zip archives
          1. Getting ready
          2. How to do it...
          3. How it works...
        9. Loading resources asynchronously
          1. Getting ready
          2. How to do it...
          3. There's more
          4. See also
        10. Storing application data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      12. 5. Cross-platform Audio Streaming
        1. Introduction
        2. Initializing OpenAL and playing the .wav files
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. See also
        3. Abstracting basic audio components
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Streaming sounds
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        5. Decoding Ogg Vorbis files
          1. Getting ready
          2. How to do it...
          3. How it works…
        6. Decoding tracker music using ModPlug
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      13. 6. Unifying OpenGL ES 3 and OpenGL 3
        1. Introduction
        2. Unifying the OpenGL 3 core profile and OpenGL ES 2
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Initializing the OpenGL 3 core profile on Windows
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Initializing OpenGL ES 2 on Android
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Unifying the GLSL 3 and GLSL ES 2 shaders
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Manipulating geometry
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Unifying vertex arrays
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Creating a wrapper for textures
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Creating a canvas for immediate rendering
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      14. 7. Cross-platform UI and Input Systems
        1. Introduction
        2. Processing multi-touch events on Android
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Setting up multi-touch emulation on Windows
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Handling multi-touch events on Windows
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Recognizing gestures
          1. Getting ready
          2. How to do it...
          3. How it works...
        6. Implementing an on-screen joypad
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Using FreeType for text rendering
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        8. Localization of in-game strings
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      15. 8. Writing a Match-3 Game
        1. Introduction
        2. Handling asynchronous multi-touch input
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Improving the audio playback mechanism
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Shutting down the application
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Implementing the main loop
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Creating a multiplatform gaming engine
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Writing the match-3 game
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Managing shapes
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        9. Managing the game field logic
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        10. Implementing user interaction within a game loop
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also…
      16. 9. Writing a Picture Puzzle Game
        1. Introduction
        2. Implementing picture puzzle game logic
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Implementing the animated 3D image selector
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Page-based user interface
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more...
          5. See also
        5. Image gallery with Picasa downloader
          1. How to do it…
          2. How it works…
          3. See also
        6. Implementing the complete picture-puzzle game
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
          5. See also
      17. Index