Game Development Reference
In-Depth Information
Generating JNI Headers
We must generate the headers for the JNI interface before we compile the DSO. Use the Makefile to do
so:
$make jni
Note that this command must be run within the native/gp2xwolf3d folder of the chapter source.
With the JNI headers in place, we can compile the DSO as follows:
$ make
If you make changes to the native code, you might wish to test for missing symbols in the DSO by
compiling a simple test program against the library (see Listing 6-20). This is a small program that calls
the game loop. It is not meant to be run but to detect linker errors (missing symbols) in the Wolf 3D
native library.
Listing 6-20. Wolf 3D Test Program Used to Detect Linker Errors
#include <stdio.h>
void _start(int argc, char **argv) {
int i;
int myargc = 4;
// wolf, wolfsw, sodemo, sod, sodm2, sodm3
char * myargv[] = {"wolf3d", "wolfsw", "basedir" , "/data/wolf/"};
for ( i = 0 ; i < myargc; i++ )
printf("argv[%d]=%s\n", i, myargv[i]);
wolf_main(myargc, myargv);
exit(0);
}
$ agcc -c test.c
$ ald -o testwolf -L. -lwolf_jni
Testing Wolf 3D in the Emulator
Let's play Wolf 3D in the emulator. Make sure to do this sanity check first: the native library is critical
and must be placed in the libs/armeabi folder of the main project (as shown in Figure 6-8). At runtime,
the library will be loaded and cached to the right location in the device.
Search WWH ::




Custom Search