Game Development Reference
In-Depth Information
Note As noted in previous chapters, Google doesn't support this type of native development, but it seems
Google is being pushed by the overwhelming number of 3D games being ported to the iPhone and other mobile
devices. So much so, that Google has recently released the Android NDK, a set of tools and header files for native
development, introduced in Chapter 1.
A Head Start: The Source Code for this Chapter
In this chapter, we'll use the Android 3D cubes sample in its original Java language, but we will also move
code to the native side. This sample is available from the Android site; however, the sample is composed
of many resources, which are bundled as part of the overall Android samples pack. To make things
simpler, I have packed the required files, plus the changes described throughout this chapter, in the
chapter source code.
If you wish, you can import the project into your workspace. To do so, select File ➞ Import. In the dialog
box, select Existing Projects into Workspace. Next, navigate to the chapter source ch06.OpenGL .
Optionally, check Copy project into workspace. When you click Finish, the automated build will load.
Try to familiarize yourself with the project layout, especially with the following folders:
src contains the Java classes used by the project.
native contains the cube renderer and the cube-drawing subroutines.
OpenGL the Java Way
Let's look at how OpenGL graphics are done within Java. For this exploration, you need to create a
project to hold the GL tumbling cubes application from the Android samples. Here is how:
1.
Click the New Android Project button.
In the New Android Project dialog box, enter a project name, such as ch05.OpenGL .
2.
3.
Specify the build target as Android 1.5.
4.
Enter an application name, such as OpenGL Java .
5.
Enter a package name, such as opengl.test .
Select Create Activity and enter JavaGLActivity .
6.
7.
Specify the minimum SDK version as 3. Figure 5-1 shows the completed dialog
box for this example.
8.
Click Finish.
Search WWH ::




Custom Search