Book Image

Android NDK Game Development Cookbook

Book Image

Android NDK Game Development Cookbook

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 (16 chapters)
Android NDK Game Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Index

A

  • Accept() method / How to do it…
  • adb command / There's more..., Getting ready
  • AddControlPoint() method / How to do it...
  • AddGround() function / How it works...
  • AddTouchPoint() function / How to do it...
  • alSourcePause() function / There's more…
  • alSourcePlay() function / How to do it…
  • Android
    • native static libraries, compiling for / Compiling the native static libraries for Android, How to do it..., How it works...
    • OpenGL ES 2, initializing on / Initializing OpenGL ES 2 on Android, How to do it…, How it works…
    • multi-touch events, processing / Processing multi-touch events on Android, Getting ready, How to do it...
  • Android activity lifecycle
    • URL / Shutting down the application
  • Android development tools
    • installing, on Windows / Installing Android development tools on Windows, How to do it..., There's more...
    • installing, on Linux / Installing Android development tools on Linux, How to do it...
  • Android NDK
    • URL / Getting ready, How to do it...
  • Android SDK
    • URL / Getting ready, How to do it...
  • animated 3D image selector
    • implementing / Implementing the animated 3D image selector, How to do it..., How it works...
  • Apache Ant
    • URL / Getting ready
  • application
    • native C++ code, adding to / Adding native C++ code to your application, How to do it..., There's more...
    • shutting down / Shutting down the application, How it works…
  • application data
    • storing / Storing application data, How to do it..., How it works..., There's more...
  • application template
    • creating / Creating an application template manually, How to do it..., How it works...
  • ArchiveReader$$ExtractSingleFile method / How to do it...
  • asynchronous callbacks invocation
    • handling / Handling asynchronous callbacks invocation, How to do it…, How it works…
  • asynchronous multi-touch input
    • handling / Handling asynchronous multi-touch input, How to do it…, There's more…
  • asynchronous network
    • working with / Working with the network asynchronously, How to do it…, How it works…
  • asynchronous resources
    • loading / Loading resources asynchronously, How to do it...
  • asynchronous task queues
    • implementing / Getting ready, How it works...
  • audio playback mechanism
    • improving / Improving the audio playback mechanism, How to do it…, How it works…

B

  • BACK button / How it works…
  • BaseURL parameter / How to do it…
  • basic audio components
    • abstracting / Abstracting basic audio components, How to do it…, How it works…, There's more…
  • Bind() method / How it works…
  • BlockRead() method / How to do it...
  • boolean parameter / How to do it...
  • Box2D
    • URL / Getting ready
  • Box2D simulations
    • setting up / Setting up Box2D simulations, How to do it..., There’s more...
  • BoxR() function / How it works...
  • bullet time
    • URL / How it works…

C

  • CalculateLineParameters function / How to do it...
  • canvas
    • creating, for immediate rendering / Creating a canvas for immediate rendering, How to do it…, There's more…
  • CFLAGS variable / How to do it...
  • CheckStatus() function / How it works…
  • clAudioThread$$Run() method / How to do it…
  • clGUIButton object / How to do it...
  • ConfigChooser class / How to do it…
  • core folder
    • about / How it works…
  • CPPFLAGS variable / How to do it...
  • CreateContextFull() function / How to do it…
  • CreateJoint() function / How it works...
  • CreateReader() method / How it works...
  • CreateWindowA() / How to do it...
  • critical section
    • URL / Synchronizing native cross-platform threads
  • cross-platform
    • about / Going cross platform, Getting ready, How to do it..., How it works…, There's more…
    • code, unifying / Unifying the cross-platform code, There's more...
  • cross-platform multithreading
    • performing / Performing cross-platform multithreading, How to do it..., How it works...

D

  • 2D
    • graphics, rendering / Rendering graphics in 2D, How to do it…, How it works…
  • DemultiplexEvents() function / How it works…
  • dlsym() function / There's more…
  • Draw() method / How it works…
  • DrawBody() function / How to do it...
  • DrawFigure() method / How it works…
  • DrawQuad() function / How it works…
  • DrawTexQuad() function / How it works…
  • DrawTile() method / How it works...

E

  • Env_Sleep() function / How to do it…
  • Event_Drag() method / How to do it...
  • Event_Fling() method / How to do it...
  • Event_Pinch() method / How to do it...
  • Event_PinchStart() method / How to do it...
  • Event_PointerChanged() method / How to do it...
  • Event_PointerMoved() method / How to do it...
  • Event_UpdateGesture() method / How to do it...
  • Exit() method / How to do it...
  • ExtractSingleFile() function / How to do it...
  • ExtractSingleFile() method / How it works...
  • ExtractURLAttribute() function / How to do it…

F

  • FBufferUsed field / How to do it…
  • FileExists() method / How it works...
  • FileMapper
    • about / How to do it...
  • files
    • enumerating, in .zip archives / Enumerating files in the .zip archives, How to do it..., How it works...
    • decompressing, from .zip archives / Decompressing files from the .zip archives, How to do it..., How it works...
  • file streams
    • abstracting / Abstracting file streams, How to do it..., How it works...
  • FileSystem$$AddAlias method / There's more...
  • file writers
    • implementing / Implementing file writers, How to do it..., How it works…
  • Fix Your Timestep!
    • URL / Getting ready
  • Flickr
    • photo list, fetching from / Fetching list of photos from Flickr and Picasa, How to do it…, How it works…, There's more…
    • images, downloading from / Downloading images from Flickr and Picasa, How to do it…, How it works…, There's more…
  • Flickr API
    • URL / There's more…
  • Flickr_GetListURL() function / How to do it…
  • flood-fill algorithm
    • URL / How it works…
  • FreeImage graphics library
    • using / Using the FreeImage graphics library, How to do it..., How it works...
  • FreeImage source code
    • URL / Getting ready
  • FreeImage_GetRowPtr() / How it works...
  • FreeImage_SaveMemory() / How it works...
  • FreeType
    • using, for text rendering / Using FreeType for text rendering, How to do it..., How it works..., There's more…
  • FreeType library
    • used, for text rendering / Using the FreeType library for text rendering, Getting ready, How to do it..., There’s more...
    • URL / Getting ready
  • fs folder
    • about / How it works…
  • FS_IsFullPath() function / How it works...

G

  • game field logic
    • managing / Managing the game field logic, How to do it…, How it works…, There's more…
  • game loop
    • user interaction, implementing within / Implementing user interaction within a game loop, How to do it…, How it works…, There's more…
  • gcc command / How it works...
  • GenerateTicks() function / How to do it...
  • GenerateTicks() method / How to do it...
  • geometry
    • manipulating / Manipulating geometry, How to do it…, How it works…
  • gestures
    • recognizing / Recognizing gestures, How to do it..., How it works...
  • GetAdaptersAddresses() function / Detecting a network address
  • GetAPI() function / How it works…, How it works…
  • getifaddrs() function / Detecting a network address, How to do it...
  • GetLocaleInfo() WinAPI function / There's more...
  • GetPosition() method / How to do it...
  • GetSeconds() function / How to do it...
  • GetSizedFace function / How to do it...
  • gettimeofday() function / How to do it...
  • GetVariableValue() function / How it works…
  • GetWaveDataSize() method / How to do it…
  • GLFW library
    • URL / Initializing the OpenGL 3 core profile on Windows
  • GLSL 1.50
    • URL / Getting ready
  • GLSL 3 shaders
    • unifying / Unifying the GLSL 3 and GLSL ES 2 shaders, How to do it…, How it works…, There's more…
  • GLSL ES 2 shaders
    • unifying / Unifying the GLSL 3 and GLSL ES 2 shaders, How to do it…, How it works…, There's more…
  • GLSurfaceView class
    • URL / Getting ready
  • Glyph caching
    • about / Getting ready
  • GNU Compiler Collection (GCC) / Getting ready
  • graphics
    • rendering, in 2D / Rendering graphics in 2D, How to do it…, How it works…
  • graphics folder
    • about / How it works…

H

  • HandleTouch() method / How to do it...
  • HTTP server
    • writing / Writing the HTTP server, How it works…, There's more…

I

  • iIStream$$BlockRead() method / How it works...
  • Image gallery
    • with Picasa downloader / Image gallery with Picasa downloader, How to do it…
  • images
    • downloading, from Flickr / Downloading images from Flickr and Picasa, How to do it…, How it works…, There's more…
    • downloading, from Picasa / Downloading images from Flickr and Picasa, How to do it…, How it works…, There's more…
  • ImgSizeType parameter / How to do it…
  • iMountPoint$$FileExists() method / How it works...
  • iMountPoint$$MapName() method / How it works...
  • in-game strings
    • localizing / Localization of in-game strings, How to do it..., There's more...
  • in-memory files
    • working with / Working with in-memory files, How it works...
  • init() method / How to do it…
  • InitKeys() method / How to do it...
  • int main() function / Getting ready
  • iOStream$$Write() method / How it works...
  • IsDraggingValid() function / How to do it...
  • IsEOF() method / How to do it...
  • IsPinchZoomValid() function / How to do it...
  • IsPlaying() function / How to do it…
  • IsPlaying() method / How to do it…
  • iThread$$Start() method / How to do it...
  • iWaveDataProvider class / How to do it…

J

  • jarsigner tool / How to do it...
  • Java SE Development Kit
    • URL / Getting ready

K

  • kerning
    • about / Getting ready
  • Khronos
    • URL / Getting ready

L

  • lfind() function / How to do it...
  • LGL folder
    • about / How it works…
  • libcurl networking library
    • compiling / Compiling the libcurl networking library, How it works…
  • libCurl source code
    • URL / Getting ready
  • libmodplug
    • compiling / Compiling libvorbis, libmodplug, and libtheora, How to do it...
    • URL / Getting ready
  • libmodplug library
    • URL / Getting ready
  • libRocket
    • URL / Getting ready
  • libtheora
    • compiling / Compiling libvorbis, libmodplug, and libtheora, How to do it...
  • libvorbis
    • compiling / Compiling libvorbis, libmodplug, and libtheora, How to do it...
  • libvorbis and libtheora codecs
    • URL / Getting ready
  • ligature
    • about / Getting ready
  • Linderdaum Engine
    • URL / How to do it...
  • Linderdaum Puzzle HD
    • URL / Getting ready
  • Linux
    • Android development tools, installing on / Installing Android development tools on Linux, How to do it...
  • LoadFileAsBlob() function / How it works…
  • LoadFontFile() function / How to do it...
  • LoadFT() function / How to do it...
  • LoadStringWithFont() function / How to do it...
  • LocalizeString() function / How to do it..., How it works...
  • Lock variable / How it works…
  • LoopSound() method / There's more…

M

  • main() function / How to do it..., How it works…
  • main loop
    • implementing / Implementing the main loop, How to do it…, There's more…
  • make all command / How it works...
  • MapName() / How it works...
  • match-3 game
    • writing / Writing the match-3 game, How to do it…, How it works…, There's more…
  • MaxResults parameter / How to do it…
  • memory
    • managing, reference counting used / Managing memory using reference counting, Getting ready, How to do it..., How it works..., There's more...
  • MemoryCallback() function / How it works…
  • MinGW GCC toolchain
    • URL / How to do it...
  • Minimalist GNU for Windows (MinGW) / Getting ready
  • MiniZIP project
    • URL / Getting ready
  • mmap() function / Getting ready
  • mount points
    • implementing / Implementing mount points, How to do it..., There's more...
  • MultColor() function / How to do it...
  • multi-touch emulation
    • setting up, on Windows / Setting up multi-touch emulation on Windows, How to do it..., How it works...
  • multi-touch events
    • processing, on Android / Processing multi-touch events on Android, Getting ready, How to do it...
    • handling, on Windows / Handling multi-touch events on Windows, How to do it..., How it works...
  • multiplatform gaming engine
    • creating / Creating a multiplatform gaming engine, How it works…
  • multiple CPU architectures
    • supporting / Supporting multiple CPU architectures, How to do it...
  • MultiTouchVista
    • URL / Getting ready
  • music tracker
    • URL / Decoding tracker music using ModPlug

N

  • native C++ code
    • adding, to application / Adding native C++ code to your application, How to do it..., There's more...
  • native cross-platform threads
    • synchronizing / Synchronizing native cross-platform threads, How to do it..., How it works...
  • native static libraries
    • compiling, for Windows / Compiling the native static libraries for Windows, How it works..., There’s more...
    • compiling, for Android / Compiling the native static libraries for Android, How to do it..., How it works...
  • ndk-build command / How it works...
  • NDK toolchains
    • switching / Switching NDK toolchains
  • network address
    • detecting / Detecting a network address, How to do it..., How it works..., There's more...
  • Net_EnumerateAdapters() function / How to do it...

O

  • ODE
    • URL / Getting ready
  • ODE physical library
    • building / Building the ODE physical library, How to do it...
  • ofstream$$write() function / How it works...
  • Ogg Vorbis files
    • decoding / Decoding Ogg Vorbis files, How to do it..., How it works…
  • OGG_ReadFunc() function / How to do it...
  • OGG_SeekFunc() function / How to do it...
  • OGG_TellFunc() function / How to do it...
  • on-screen joypad
    • implementing / Implementing an on-screen joypad, How to do it..., How it works...
  • OnDrawFrame() callback / How it works…
  • OnKey() method / How to do it..., How it works…
  • OnKeyDown() function / How it works…
  • OnKeyUp() function / How it works…
  • OnMouseDown() function / How it works…
  • OnMouseMove() function / How it works…
  • OnMouseUp() function / How it works…
  • onPause() method / How to do it…
  • OnStart() function / How it works…
  • OnStart() method / How it works...
  • OnStop() method / There's more…
  • OnTimer() callback / There's more…
  • OnTimer() method / How to do it...
  • onTouchEvent() function / How it works...
  • onTouchEvent() method / Getting ready
  • OpenAL
    • initializing / Initializing OpenAL and playing the .wav files, How to do it…
  • OpenAL library
    • compiling / Compiling the OpenAL library, How to do it...
  • OpenGL
    • URL / Getting ready, Getting ready
  • OpenGL 3 core profile
    • unifying / Unifying the OpenGL 3 core profile and OpenGL ES 2, How to do it…, There's more…
    • initializing, on Windows / Initializing the OpenGL 3 core profile on Windows, How to do it…, How it works…, There's more…
  • OpenGL ES
    • used, for rendering with / Basic rendering with OpenGL ES, How to do it…, How it works…
  • OpenGL ES 2
    • unifying / Unifying the OpenGL 3 core profile and OpenGL ES 2, How to do it…, There's more…
    • initializing, on Android / Initializing OpenGL ES 2 on Android, How to do it…, How it works…
  • OpenGL ES documentation
    • URL / Getting ready

P

  • page-based user interface
    • about / Page-based user interface, How to do it..., How it works…, There's more...
  • PageIndex parameter / How to do it…
  • parametric equation
    • URL / How to do it...
  • pentomino
    • URL / Getting ready
  • photo list
    • fetching, from Flickr / Fetching list of photos from Flickr and Picasa, How to do it…, How it works…, There's more…
    • fetching, from Picasa / Fetching list of photos from Flickr and Picasa, How to do it…, How it works…, There's more…
  • physics
    • timing, implementing / Implementing timing in physics, How to do it..., How it works...
  • Picasa
    • photo list, fetching from / Fetching list of photos from Flickr and Picasa, How to do it…, How it works…, There's more…
    • images, downloading from / Downloading images from Flickr and Picasa, How to do it…, How it works…, There's more…
  • Picasa downloader
    • image gallery, using with / Image gallery with Picasa downloader, How to do it…
  • Picasa_GetListURL() function / How to do it…
  • picture-puzzle game
    • implementing / Implementing the complete picture-puzzle game, How to do it…, How it works…, There's more...
  • picture puzzle game logic
    • implementing / Implementing picture puzzle game logic, Getting ready, How to do it..., How it works...
  • Play() method / How to do it…, How to do it…
  • portable memory-mapped files
    • implementing / Implementing portable memory-mapped files, How to do it..., How it works...
  • printf() function / How it works…
  • ProcessClick() function / How it works…
  • pulse-code modulation
    • URL / Initializing OpenAL and playing the .wav files

Q

  • QuadCoords() method / How to do it...

R

  • RAII registration
    • URL / How it works…
  • ReadFileData() function / How to do it...
  • ReadFromFile() function / How to do it...
  • ReadFromFile() method / How to do it...
  • read_bmp_mem() function / How to do it...
  • RebindAllUniforms() method / There's more…
  • reference counting
    • used, for managing memory / Managing memory using reference counting, Getting ready, How to do it..., How it works..., There's more...
  • release Android applications
    • signing / Signing release Android applications, How to do it...
  • Reload() function / How it works…
  • Render() method / How it works…
  • RenderDirect() function / How it works...
  • RenderDirect() method / How to do it…
  • Renderer class / How to do it…
  • rendering
    • with OpenGL ES / Basic rendering with OpenGL ES, How to do it…, How it works…
    • canvas, creating for / Creating a canvas for immediate rendering, How to do it…, How it works…
  • REST (Representational State Transfer) / Fetching list of photos from Flickr and Picasa
  • Restart() method / How to do it...
  • Retoss() method / How to do it...
  • Run() method / How to do it..., How to do it..., How to do it…, How it works…

S

  • Seek() method / How to do it...
  • SendMotion() function / How to do it...
  • SetTimer() function / How to do it...
  • Setup() function / How it works...
  • SetVariableValue() function / How it works…
  • SetVertexAttribs() method / How to do it…
  • SetVolume() method / How to do it…
  • shapes
    • managing / Managing shapes, How it works…
  • sound folder
    • about / How it works…
  • sounds
    • streaming / Streaming sounds, How to do it…, How it works…, There's more…
  • source code
    • organizing / Linking and source code organization
    • linking / Linking and source code organization
  • StackOverflow
    • URL / How to do it...
  • Step() method / How it works...
  • Stop() method / How to do it…
  • StreamWaveData() method / How it works…
  • Str_AddTrailingChar() function / How it works...
  • SwapBytes() function / There's more…
  • switch statement / How it works…

T

  • text rendering
    • FreeType library, using for / Using the FreeType library for text rendering, Getting ready, How to do it..., There’s more...
    • FreeType, using for / Using FreeType for text rendering, How to do it..., How it works..., There's more…
  • textures
    • wrapper, creating for / Creating a wrapper for textures, How to do it…, There's more…
  • threading folder
    • about / How it works…
  • time slicing / How it works...
  • timing
    • implementing, in physics / Implementing timing in physics, How to do it..., How it works...
  • toolchain
    • about / Switching NDK toolchains
  • tracker music
    • decoding, ModPlug used / Decoding tracker music using ModPlug, How to do it..., How it works...

U

  • UnqueueAll() method / How to do it…
  • Update() method / How to do it…, How to do it..., How to do it...
  • UpdateGesture() function / How to do it...
  • user interaction
    • implementing, within game loop / Implementing user interaction within a game loop, How to do it…, How it works…, There's more…
  • usleep() function / How to do it…

V

  • VAO
    • about / Unifying vertex arrays
  • VBO
    • about / Unifying vertex arrays
  • vertex arrays
    • unifying / Unifying vertex arrays, Getting ready, How to do it…, How it works…, There's more…
  • Viewport_ProcessMotion() function / How it works...
  • Viewport_UpdateTouchPoint() function / How to do it...

W

  • .wav files
    • playing / Initializing OpenAL and playing the .wav files, How to do it…
  • wglCreateContextAttribsARB() function / How to do it…
  • WGL_ARB_pixel_format
    • URL / How to do it…
  • Windows
    • Android development tools, installing on / Installing Android development tools on Windows, How to do it..., There's more...
    • native static libraries, compiling for / Compiling the native static libraries for Windows, How it works..., There’s more...
    • OpenGL 3 core profile, initializing on / Initializing the OpenGL 3 core profile on Windows, How to do it…, There's more…
    • multi-touch emulation, setting up / Setting up multi-touch emulation on Windows, How to do it..., How it works...
    • multi-touch events, handling / Handling multi-touch events on Windows, How to do it..., How it works...
  • wrapper
    • creating, for textures / Creating a wrapper for textures, How to do it…, There's more…

X

  • XOR pattern
    • URL / How it works…

Z

  • .zip archives
    • files, enumerating / Enumerating files in the .zip archives, How to do it..., How it works...
    • files, decompressing / Decompressing files from the .zip archives, How to do it..., How it works...