Thursday, July 19, 2012

OgreKit not support viewport orientation in Android

As I've compiled the GameKit Android demo .apk and downloaded to by Android phone, it crashed!! Debugging info shown below:

0688): OGRE EXCEPTION(9:UnimplementedException): Setting Viewport orientation mode is not supported in setOrientationMode at /Users/erikvillegas/Development/Android/gamekit-read-only/Ogre-1.8rc/OgreMain/src/OgreViewport.cpp (line 226)

Then, I open OgreViewport.cpp to take alook:

void Viewport::setOrientationMode(OrientationMode orientationMode, bool setDefault) {
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
                    "Setting Viewport orientation mode is not supported",
                    __FUNCTION__);
#endif
        mOrientationMode = orientationMode;

        if (setDefault){
            setDefaultOrientationMode(orientationMode);
        }

        if (mCamera){
            mCamera->setOrientationMode(mOrientationMode);
        }

}

Obviously, the compile option "
OGRE_NO_VIEWPORT_ORIENTATIONMODE" is not ZERO. Then, I grep -ir "OGRE_NO_VIEWPORT_ORIENTATIONMODE" * and found that it's value should be assigned from the CMake header configure file inside "./trunk/Ogre-1.8rc/Settings/OgreBuildSettings.h.in" and

#define OGRE_NO_VIEWPORT_ORIENTATIONMODE @OGRE_SET_DISABLE_VIEWPORT_ORIENTATIONMODE@


Then, I grep all the files with defined OGRE_SET_DISABLE_VIEWPORT_ORIENTATIONMODE and set it as ZERO, especially the CMake/configOgreKit.cmake, CMake/configureBuild.cmake, and the most important, ./trunk/Ogre-1.8rc/CMakeLists.txt.


Rebuild the dev. folder by "sudo ./configure_android ../android_lib debug"
Goto ../android_lib/make


..wait for the compilation finished... and the view port orientation mode should be disabled.


Here we go!

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