Open Source Android Apps for Developers: Kwaak3
Kwaak3 (Port of a famous 3d shooter to Android) is an open source Android project which is a port of Quake3 to Android. Kwaak3 includes the following features:
* Hardware floating-point on Neon-capable devices
* Input: keyboard, touchscreen and trackball
* OpenGL 3D rendering
* Game uses ARM optimized libcgamearm.so / libqaarm.so / libuiarm.so
Normally when you compile C/C++ code using the Android NDK, the compiler targets a generic ARMv5 CPU which uses software floating-point. Without any optimizations and audio Quake3 runs at 22fps. Since Quake3 uses a lot of floating-point calculations. I tried a better C-compiler (GCC 4.4.0 from Android GIT) which supports modern CPUs and Neon SIMD instructions. Quake3 optimized for Cortex-A8 with Neon is about 15% faster without audio and 35% with audio compared to the generic ARMv5 build. Most likely the performance improvement compared to the ARMv5 build is not that big because the system libraries of the Milestone have been compiled with FPU support, so sin/cos/log/.. take advantage of the FPU.
# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://kwaak3.googlecode.com/svn/trunk/ kwaak3-read-only
Android programs are written in Java and performance critical parts can be implemented in a C library and can then be called using JNI. 99.9% of the code in this project is C and the other part is Java. The small Java part initializes OpenGL, handles input and manages audio. The Kwaak3 Java code communicates with a ‘libquake3.so’ using a libkwaakjni wrapper. This wrapper loads either a generic ARMv5 ‘libquake3.so’ or a Neon optimized ‘libquake3_neon.so’ depending on the CPU.
* Ioquake3 contains an ‘infinite’ loop which renders a single frame each iteration. A single iteration of this loop has been turned into a function which is called from onDrawFrame in Java.
* Input is processed by Android and is sent to the game when it is received.
* Audio is implemented on the Java side and using JNI, kwaak3 requests a number of audio samples when it needs some.
During development I have only had access to a Motorola Milestone. This phone has a keyboard and for this reason the game has been optimized for devices with a keyboard, so it won’t work on your Nexus One or other phone at this point. One of my testers used a G1 and thanks to his testing there is also some trackball support. If I had my hands on more devices I would add support for those devices. The minimum required Android version at this point is 1.6.
Note the G1 doesn’t have much RAM and due to this is very sensitive to crashing. The game might be more stable if you disable audio.
* Audio: use direct buffers to make data copying to Java more efficient and optimize the mixing code using Neon instructions
* 3D rendering: use VBOs for uploading geometry and prevent unneeded re-uploads
* Input: improve controls on phones without keyboard like the Nexus One
* Profile: profile the Quake3 code and optimize slow parts
* Download the kwaak3.apk from the download section and install it on your phone. (Note you need at least Android 1.6)
* Create a directory quake3 in the root of your sdcard and also create a baseq3 directory inside it.
* Copy pak0.pk3 of your Quake3 CD (or from the demo) to the quake3/baseq3 directory.
* Download the Quake3 1.32 point release and copy pak1-pak8.pk3 to quake3/baseq3
* Start the game
Posted by Cute Android
Related Android Apps:
- Open Source Android Apps for Developers: Dex2jar
- Open Source Android Apps for Developers: JRuby-for-android
- Open Source Android Apps for Developers: Libgdx
- Open Source Android Apps for Developers: Zxing
- Open Source Android Apps for Developers: Dialerone
- Open Source Android Apps for Developers: WebSMSdroid
- Open Source Android Apps for Developers: Android2cloud
- Open Source Android Apps for Developers: Forget3d
- Open Source Android Apps for Developers: Connectbot
- Open Source Android Apps for Developers: k9mail