Wednesday, July 18, 2012

Ogrekit for Android

I'm fond of 3D games and found an open-sourced game kit called "OgreKit" developed by an volunteer. It makes use of OpenGL ES 2.0 in Android and the popular rendering engine - Ogre 3D, to form a game engine. Ok, let's play around with it.

1. goto http://code.google.com/p/gamekit/source/checkout
2. follow the instruction to download the source code in Terminal of your linux box:

svn checkout http://gamekit.googlecode.com/svn/trunk/ gamekit-read-only

3. going into su: type "sudo su"
4. vim ~/.bashrc
5. add environment variables to the bash shell (.bashrc)

PATH="/home/henryl/android-sdks/tools:/home/henryl/android-sdks/platform-tools:/home/henryl/android-ndk-r8:${PATH}"
export PATH

NDK="/home/henryl/android-ndk-r8"
export NDK

NDK_BIN="${NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin"  
export NDK_BIN
6. restart Terminal and type "sudo su"
7. go into the "./gamekit-read-only/trunk" and type:
"./configure-android ../build_android" <- you use mkdir ../build_android first
8. cd ../build_android && make
9. after the lengthy compilation, the baked "libogrekit.so" will be placed inside "./build_android/Samples/AndroidDemo/Shared"

Then, we can build an Android apps for using this JNI library.
1. copy libogrekit.so to ./trunk/Samples/AndroidDemo/Demo/libs
2. Goto Eclipse -> New -> Android application from existing code ->
browser to "./trunk/Samples/AndroidDemo/Demo" and finished.
3. copy the asset folder's "asset/gk_android.blend" to /sdcard/gamekit/gk_android.blend.
4. build, download to device and RUN...Here we go!!

references:
http://gamekit.org/forum/viewtopic.php?t=29
http://code.google.com/p/gamekit/

Updated 20120929::
A.)while checkout latest gamekit via
- svn checkout http://gamekit.googlecode.com/svn/trunk/ gamekit-read-only, the "trunk" folder have been removed by designer. And as you run "cmake-gui" by root user (i.e. sudo su) and configure the makefile, you can't setup the android NDK path any more. So, env. variable "OPENGLES2_INCLUDE_DIR" cannot be generated from the cmake tool....so, the workaround is by adding a line 
>>> "set(OPENGLES2_INCLUDE_DIR /home/henryl/android-ndk-r8/platforms/android-9/arch-arm/usr/include)
" inside ./gamekit_root/CMakeLists.txt to do so.


B.) And one more thing, is that while exec. ./configure-android ../build_android, an error 
missing "ANDROID_NDK" env. variable, so, we need to .... 
>>> vim ~/.bashrc
>>> add a line at the end
ANDROID_NDK="/home/henryl/android-ndk-r8"
export ANDROID_NDK



No comments:

Post a Comment