Game Development Reference
In-Depth Information
Chapter 2
Java for Android
In this chapter, I will cover the Java language component in Android 3D games development. I will
start with a brief overview and review of the basic Java language on Android. Then I cover the basic
Java program framework on Android for all applications. Next, I cover the basic Java program
framework on Android for applications that specifically utilize OpenGL ES graphics. Finally, I provide
a hands-on example of a 3D Android OpenGL ES program.
Overview of the Java Language
This section on the Java language is intended as a quick-start guide for someone who has
some knowledge of computer programming as well as some knowledge about object-oriented
programming. This section is not intended to be a Java reference manual. It is also not intended to
cover every feature of the Java programming language.
The Java language for Android is run on a Java virtual machine. This means that the same compiled
Java Android program can run on many different Android phones with different central processing
unit (CPU) types. This is a key feature in terms of future expandability to faster processing units,
including those that will be specifically designed to enhance 3D games. The trade-off to this is
speed. Java programs run slower than programs compiled for a CPU in its native machine language,
because a Java virtual machine must interpret the code and then execute it on the native processor.
A program that is already compiled for a specific native processor does not have to be interpreted
and can save execution time by skipping this step.
However, you can compile C/C++ code for a specific Android processor type using the Android
Native Development Kit or NDK. You can also call native C/C++ functions from within the Java
programming framework. Thus, for key functions that require the speed of natively compiled code,
you can put these functions into C/C++ functions that are compiled using the NDK and called from
Java code in your main program.
29
 
Search WWH ::




Custom Search