Game Development Reference
In-Depth Information
.println("Loading JNI lib using abs path:" + LIB_PATH);
System.load(LIB_PATH);
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
try {
mGLSurfaceView.setRenderer(new CubeRenderer(true, true));
setContentView(mGLSurfaceView);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
// Ideally a game should implement onResume() and onPause()
// to take appropriate action when the activity loses focus
super.onResume();
mGLSurfaceView.onResume();
}
@Override
protected void onPause() {
// Ideally a game should implement onResume() and onPause()
// to take appropriate action when the activity loses focus
super.onPause();
mGLSurfaceView.onPause();
}
}
The following new files will be added to the project (see Figure 5-5):
Native activity : This is the main entry point to the application. It can be run from
its own launcher on the device.
Native interface class : This is a new Java class that contains the native methods to
be invoked within the renderer thread.
Native cube renderer ( cuberenderer.c ): This is the C equivalent of
CubeRenderer.java . It initializes the scene and draws a frame. It also contains all
the JNI callbacks.
Native cube ( cube.c ): This file is equivalent to Cube.java ; it draws the cube.
Three files will be updated to accommodate the native calls: CubeRenderer ,
GLSurfaceView, and GLThread.
Search WWH ::




Custom Search