Game Development Reference
In-Depth Information
The sources folder from the NDK folder structure is gone (see the section on Wolf
3D and NDK 1.5). Now, all code (Java and native) lives in the apps folder. Within
the apps folder, the project folder contains the Android Java project, and within
project , the jni folder contains the native code and the Makefile Android.mk .
NDK 1.6 adds support for OpenGL ES 2.0. This welcome addition will help many
3D games out there.
I would recommend the NDK over the CodeSourcery G++ compiler if you have a slow system such
as a laptop or VMware combination or if your library crashes mysteriously, perhaps because of GNU
compiler version issues, which can happen in programs that are not highly portable. Discrepancies in
the GNU compiler version (for example, CodeSourcery uses GCC 4.3.x instead of Android's 4.2.x) can
cause optimization errors and other types of runtime errors that ultimately crash the game.
All in all, NDK 1.6 is a good improvement but still has far to go to catch up with other powerful tools,
such as Apple's iPhone Xcode platform. For example, the NDK will recompile the entire library if you
change the Makefile, Android.mk (too add a new source file for example). This is really annoying when
you have a big library with lots of source files. Other tools such as GNU make will detect the changes and
recompile only the right files in the library. Anyway, for Doom, the folder structure for NDK 1.6 should
look as follows:
android-ndk-1.6_r1/apps/Doom/Application.mk : This file defines the module
name to be built.
android-ndk-1.6_r1/apps/Doom/project : This folder contains the actual Android
project for the game.
android-ndk-1.6_r1/apps/Doom/project/jni : This folder contains the native code
and the Makefile, Android.mk .
Here is how you get Doom to compile with NDK 1.6:
1. Create android-ndk-1.6_r1/apps/Doom/Application.mk . This file contains the
module ( doom ) that we are building:
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := doom
2. Create the folder android-ndk-1.6_r1/apps/Doom/project . Copy the Android
project from ch07.Android.Doom to this folder. You don't need to copy the
native folder (this is the native code).
3. Create the folder android-ndk-1.6_r1/apps/Doom/project/jni , and copy the
native code from ch07.Android.Doom/native/prboom .
4. Create a Makefile called Android.mk in android-ndk-1.6_r1/apps/Doom/
project/jni . This make file should look as follows:
LOCAL_PATH := $(call my-dir)
# clear vars
include $(CLEAR_VARS)
# module name
LOCAL_MODULE := doom
Search WWH ::




Custom Search