Game Development Reference
In-Depth Information
// Send pixels to Java
jni_send_pixels(pixels);
}
At this point, the Doom engine is all set and ready for compilation.
Compiling Doom with the NDK
Since the release of the NDK 1.6 and later, Google has made a lot of nice improvements to
support native development. At the time of this writing, the NDK release r10d was used. The
most important changes of this new version of the NDK can be found at
https://developer.
All in all, the NDK 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
(to 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. At any rate, for Doom the folder structure for the NDK should look
as follows:
NDK_ROOT/apps/Doom/Application.mk
: This file defines the module name
to be built.
NDK_ROOT/apps/Doom/project
: This folder contains the actual Android
project for the game.
NDK_ROOT/apps/Doom/project/jni
: This folder contains the native code
and the Makefile,
Android.mk
.
The following steps show you how to get Doom to compile with the NDK:
1.
Create
android-ndk_r1/apps/Doom/Application.mk
. This file contains
the module (
doom
) that you are building.
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := doom
2.
Create the folder
NDK_ROOT/apps/Doom/project
. Copy the Android
project from
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_r1/apps/Doom/project/jni
and copy
the native code from
ch05.Android.Doom/native/prboom
.
4.
Create a Makefile called
Android.mk
in
NDK_ROOT/apps/Doom/project/
jni
. This Makefile should appear as follows: