Game Development Reference
In-Depth Information
Figure 2-15. The output of the new Android NDK example
You got your feet wet in this section, but there is so much more you can do with native apps.
You have learned the basics of Java/C interaction, which serve as the foundation for the next
section, where you'll build upon previous knowledge. You'll learn more advanced techniques
such as how to cascade audio, video, and other types of events into the native side. You'll
start with the concept of thin Java wrappers and how they can help with efficient event
handling. Audio is the simplest and therefore your starting point. Next, things get tough with
video events where you'll learn about software, hybrid, and hardware renderers. Then you'll
finish with input events via keyboard or touch screen. Let's get started.
Java Wrappers for C/C++ Event Handling
As a game developer in your organization, you probably have to build your code to support
multiple platforms. Java is an elegant object-oriented language, but when it comes to max
performance, it simply stinks. Many people would disagree with this statement, claiming that
the Just in Time (JIT), a.k.a. dynamic compilation, nature of the Java language puts it at par
with C performance-wise. This is simply not true. Any game developer who has worked in
both languages and is concerned with squeezing every single bit of speed into a device will
tell you that Java code is at least six times slower than raw native C, especially if you work
in advanced OpenGL graphics. As a matter of fact, if you take a look at the underpinnings
of the Android source, you'll find out that most of the Java APIs are simply JNI wrappers to
a bunch of C libraries, especially when it comes to audio/video, which has been improved
greatly with Android SDK 5.0.1.
 
Search WWH ::




Custom Search