Table of Contents
Mastering Android NDK
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Using Command-line Tools
Using Android command-line tools on Windows
Using Android command-line tools on OS X
Using Android command-line tools on Linux
Creating an Ant-based application template manually
Creating a Gradle-based application template manually
Embedding native code
Building and signing release Android applications
Organizing the cross-platform code
Using TeamCity continuous integration server with Android applications
Summary
2. Native Libraries
Dealing with precompiled static libraries
Dynamic linking on Windows platform
Curl
OpenSSL
FreeImage
Loading and saving images
FreeType
Theora
OpenAL
Linking the libraries to your application
Summary
3. Networking
Intrusive smart pointers
Portable multithreading primitives
Task queues
Message pumps and asynchronous callbacks
Asynchronous networking with libcurl
Android licensing in native applications
Flurry analytics
Summary
4. Organizing a Virtual Filesystem
Mount points
Mount points and streams
Accessing files on the host filesystems
In-memory files
Aliasing
Writing files
Accessing the archive files
Accessing application assets
Summary
5. Cross-platform Audio Streaming
Initialization and playback
Streaming sounds
Stringed musical instrument model
Decoding compressed audio
Decoding tracker music using the ModPlug library
Decoding MP3 files
Decoding OGG files
Summary
6. OpenGL ES 3.1 and Cross-platform Rendering
Linear algebra and transformations
Graphics initialization using SDL2
OpenGL API binding
Cross-platform OpenGL abstractions
Feeding the geometry data to OpenGL
Shader programs
Textures
Summary
7. Cross-platform UI and Input System
Rendering
Text rendering
Calculating glyph positions and string size in pixels
Decoding UTF-8
Glyphs rendering
Font initialization and caching
Integrating the text renderer into the canvas
Organizing the UI system
The base UI view
Events
Implementing UI classes
Using views in application
Summary
8. Writing a Rendering Engine
The scene graph
Lighting and shading
Lights and light nodes
Material system
Demo application and a rendering technique
Scene construction
User interaction with 3D scenes
Summary
9. Implementing Game Logic
Boids
Implementation of the flocking algorithms
Digression: helper routines
Collective behaviors
Rendering the swarm
Boids demonstration
The page-based user interface
Summary
10. Writing Asteroids Game
Creating an on-screen joystick
Implementing the particle system
Using particle systems in the game
Using particle systems inside a scene graph
Asteroids game
Summary
Index
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2015
Production reference: 1250915
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-833-3
www.packtpub.com
Authors
Sergey Kosarevsky
Viktor Latypov
Reviewers
Koji Hasegawa
Raimon RĂ fols
Sebastian Roth
Ali Utku Selen
Commissioning Editor
Priya Singh
Acquisition Editor
Tushar Gupta
Content Development Editor
Neeshma Ramakrishnan
Technical Editor
Dhiraj Chandanshive
Copy Editors
Janbal Dharmaraj
Kevin McGowan
Project Coordinator
Shweta H Birwatkar
Proofreader
Safis Editing
Indexer
Hemangini Bari
Production Coordinator
Nitesh Thakur
Cover Work
Nitesh Thakur
Sergey Kosarevsky is a software engineer with experience in C++ and 3D graphics. He worked for mobile industry companies and was involved in mobile projects at SPB Software, Yandex, Layar and Blippar. He has more than 12 years of software development experience and more than 6 years of Android NDK experience. Sergey got his PhD in the field of mechanical engineering from St. Petersburg Institute of Machine-Building in Saint-Petersburg, Russia. In his spare time, Sergey maintains and develops an open source multiplatform gaming engine, the Linderdaum Engine (http://linderdaum.com).
Viktor Latypov is a software engineer and mathematician with experience in compiler development, device drivers, robotics, and high-performance computing and with a personal interest in 3D graphics and mobile technology. Surrounded by computers for more than 20 years, he enjoys every bit of developing and designing software for anything with a CPU inside. Viktor holds a PhD in applied mathematics from Saint-Petersburg State University.
Koji Hasegawa is an iOS/Android app developer, living in Japan. He released various applications to the AppStore, such as "Den-Ace quiz, Minoru Kawasaki's tokusatsu movies world", and "Futsal rules and trivia".
In addition, he is also involved in community activities related to test automation. Koji has authored a few books on testing and test automation in Japanese.
He is an ISTQB Certification Tester and is also certified in Iaido (Japanese Sword Arts) and Kyudo (Japanese Archery).
Raimon RĂ fols has been developing for mobile devices since 2004. He has experience in developing on several technologies specializing in the UI, build systems, and client-server communications. He is currently working as an engineering manager at AXA Group Solutions in Barcelona. In the past, he worked for Imagination Technologies near London and Service2Media in the Netherlands. In his spare time, he enjoys programming, photography, and giving talks on Android performance optimization and Android custom views at mobile conferences.
Ali Utku Selen is a system engineer at Sony Mobile Communications, working on flagship Android de...