Game Development Reference
In-Depth Information
This takes care of the thin Java wrappers for Quake. Now you need to modify the C engine
slightly to make it work nicely with this Java code.
Changes Required to the Native Quake Engine
Thanks to NanoGL you can keep about 95% of the engine intact. A line count of all the
C code (including headers) equals about 75,000 lines of code. Here you realize the amount
of work you have saved; thank you again, NanoGL! (There are no words to describe how
wonderful this tiny piece of software is). Nevertheless, there are still some cosmetic changes
you need to make to the engine to make it play nicely with Android. The following is an
overview of what is needed:
Video handler : A video handler is usually required for all platforms
where the engine is to be compiled. This is the most difficult and
time-consuming change.
Movement handlers : Custom handlers for pitch, yaw, forward, and side
movement required to work with their JNI counterparts.
Audio handler : A simple audio handler is needed to configure the native
audio buffer and copy its contents to the JNI audio buffer used by the
Java MediaTrack API.
Game loop : The main method of the engine needs to be modified
slightly to work with the Android renderer thread.
Video Handler Changes
The video handler file is called gl_vidandroid.c and it is located in the project source under
ch06.Quake/jni/Quake/android . It is a pretty big file, so I will explain the most important
tasks it performs. Every OpenGL video handler must implement a set of standard functions
that will be called at certain points on the engine execution, including the following:
VID_Init : Initializes the video subsystem (see Listing 6-10). It has
one argument: an array of bytes representing a 256-size color palette
encoded as RGB color elements (1 byte per element, 768 in total).
VID_Init performs the following tasks:
It loads video user parameters, such as the width and height of the
screen (by calling COM_CheckParm ).
It sets the values for the video data structure, including width,
height, and others.
It loads the NanoGL wrapper. This must be done before any calls to
the OpenGL ES API are performed.
It initializes the OpenGL pipeline.
 
Search WWH ::




Custom Search