Game Development Reference
In-Depth Information
Believe or not, Quake II is so portable that some folks took the time to bring the game to
pure Java 3D: the name of the project is Jake 2 ( www.bytonic.de/html/jake2.html ) . There
is even a port of Quake II by Google that runs on a web browser using WebGL. As a matter
of fact, when Android was in its infancy and the NDK didn't even exist, I took a couple of
weeks to get Jake 2 to compile on Android's Dalvik VM. It was a lot of hard work just to find
out that Java is simply not capable of handling any kind of powerful 3D game engine due to
the constraints it imposes on the developer.
When thinking of a project like Jake 2, the key is the amount of RAM required to play
the game: 80MB. This is why there will never be a powerful 3D engine written in Java on
Android. The Android Java VM only lets programs allocate a maximum of 16MB of
RAM—and this cannot be changed. As any Java developer knows, on the PC, the size of the
heap (or RAM) can be changed at runtime with a simple command-line argument. This is not
possible in Android. I found this out the hard way when playing with Jake 2. All powerful 3D
engines must be written in C/C++; there is simply no way around this.
Note Writing game engines in C/C++ allows the developer to use disk space and RAM in any
way he or she chooses, limited only by what the hardware can provide. Java, on the other hand,
shackles you to 16MB of RAM.
Taming the Mighty Quake II Engine
To make the Quake II engine work seamlessly in Android, you will reuse most of the Java
wrappers from Chapter 6. You'll also have to implement custom video and audio handlers
for this particular engine. All in all, most of the work will basically consist of the following:
About 2,000 lines of new C code (for the video and audio handling).
The Java code from Chapter 6, with tiny changes to make it fit Quake II.
If you dig around the source of both the Quake I and II engines, you will realize there is
a whole lot of common code between them. Nevertheless, Quake II has been greatly
modularized (in comparison to Quake I), consisting of basically the following three
separate components:
The client : In Linux, this is the game executable, dubbed quake2 .
The game library : Quake II was designed to work with a plethora of
mission packs, extensible mods, and so forth. By decoupling the game
library into a separate component, mod developers can simply create
new games by writing a new game library, leaving the other components
intact.
The renderer : Quake II supports two renderer types: software and
hardware (using Open GL). In Linux, the renderers are called ref_soft.
so for software and ref_glx.so (for OpenGL under UNIX/Window). Note
that there are multiple OpenGL renderer implementations, each with
different names.
 
 
Search WWH ::




Custom Search