Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android NDK Game Development Cookbook

You're reading from   Android NDK Game Development Cookbook 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.

Arrow left icon
Product type Paperback
Published in Nov 2013
Publisher Packt
ISBN-13 9781782167785
Length 320 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Sergey Kosarevsky Sergey Kosarevsky
Author Profile Icon Sergey Kosarevsky
Sergey Kosarevsky
Viktor Latypov Viktor Latypov
Author Profile Icon Viktor Latypov
Viktor Latypov
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Establishing a Build Environment 2. Porting Common Libraries FREE CHAPTER 3. Networking 4. Organizing a Virtual Filesystem 5. Cross-platform Audio Streaming 6. Unifying OpenGL ES 3 and OpenGL 3 7. Cross-platform UI and Input Systems 8. Writing a Match-3 Game 9. Writing a Picture Puzzle Game Index

Linking and source code organization

In the previous recipes, we learned how to create basic wrappers that allow us to run our application on Android and Windows. However, we used an ad-hoc approach since the amount of source code was low and fit into a single file. We have to organize our project source files in a way suitable for building the code for larger projects in Windows and Android.

Getting ready

Recall the folder structure of the App3 project. We have the src and jni folders inside our App2 folder. The jni/Android.mk, jni/Application.mk, and build.xml files specify the Android build process. To enable the Windows executable creation, we add a file named Makefile, which references the main.cpp file.

How to do it...

The following is the content of Makefile:

CC = gcc
all:
  $(CC) -o main.exe main.cpp -lgdi32 -lstdc++

The idea is that when we add more and more OS-independent logic, the code resides in .cpp files, which do not reference any OS-specific headers or libraries. For the first few chapters, this simple framework that delegates frame rendering and event handling to portable OS-independent functions (OnDrawFrame(), OnKeyUp() and so on) is enough.

How it works...

All of our examples from the subsequent chapters are buildable for Windows from the command line using a single make all command. Android native code is buildable with a single ndk-build command. We will use this convention throughout the rest of the book.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image