Game Development Reference
In-Depth Information
Figure 11-9. The shared library generated by the ndk-build script
Modifying the MyGLRenderer Class
In order to use the compiled native code, we have to make some modifications to the
MyGLRenderer class from our hands-on example from the previous chapter.
The shared library with the native code has to be loaded using the loadLibrary() function.
static {
System.loadLibrary("hello-jni");
}
The native C function in the library has to be declared with the native keyword, in order to be
recognized and used.
public native String RobsstringFromJNI();
In the onDrawFrame() function, the String variable TestJNIString is assigned the return value from
calling the RobsstringFromJNI() function. This return value is incorporated in a debug log statement.
(See Listing 11-8.)
 
Search WWH ::




Custom Search