Skip to content

Ogre:Android

Ogre3D를 Android 플랫폼에 포팅하는 방법.

Download

Download the dependencies and extract inside the OGRE src dir. The deps are compiled for armeabi and armeabi-v7a.

http://sourceforge.net/projects/ogre/files/ogre-dependencies-android/1.9/AndroidDependencies_17_12_2012.zip/download

Building for Android on Windows host

Download and install the android sdk:

http://developer.android.com/sdk/index.html

After the install open the "Android SDK Manager" and download & install your target API

Here we target the lowest possible API - which is API10 Android 2.3.3.

Due the usage of the native activity and the asset manager if we would skip these we could go a bit lower but that would not make much sense because OGRE still needs a decent hardware to run.

Now add the install directory to your enviroment variables

ANDROID_SDK = C:\Users\wolfmanfx\AppData\Local\Android\android-sdk

Append %ANDROID_SDK%\tools and %ANDROID_SDK%\platform-tools to your PATH variable

Download the android ndk

  • Extract the content to C:/android/ndk and create a env var %ANDROID_NDK%
  • Add %ANDROID_NDK% to your PATH
http://dl.google.com/android/ndk/android-ndk-r8c-windows.zip
Android NDK revision 8b is not supported due a bug in the toolchain

We need ant to build projects from the command line

Apache Ant(TM) version 1.8.4 compiled on May 22 2012

cmake build

The build command for the deps, using Visual Studio command prompt (this is necessary only if you are building the dependencies from source)

cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\cmake\android.toolchain.cmake -DANDROID_ABI=armeabi ..
nmake

The build command for ogre create a build dir inside the OGRE src tree and cd to this dir and execute this command:

## for armeabi - if you want to build for armeabi v7a just remove -DANDROID_ABI=armeabi
cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\cmake\toolchain\android.toolchain.cmake -DOGRE_DEPENDENCIES_DIR=..\AndroidDependencies -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 ..

You may have to call nmake after executing the cmake script. Currently there are a couple targets in the system which you can see by typing nmake help If you want to build the old OgreSampleBrowser, which you can download from the Google Play Store, you have to type nmake SampleBrowserDummy

nmake SampleBrowserDummy

Currently, the default value is the JNI Sample, which might not be complete just yet.

Note: standardNMakecan only build one file at a time. For functionality similar to ``make -j`` (parallel builds), useJOMin place of the ``nmake`` command above.JOMcan be found here:http://qt-project.org/wiki/jom

Once you have successfully built Ogre with nmake or JOM, you still need to make the SampleBrowser app itself. This is a native activity and the project resides in a SampleBrowserNDK subdirectory of the build directory you provided earlier. Change to this directory, run ndk-build all (optionally with a -j option for parallel build), and then ant debug install to build a debug APK and install it to your device.

Building for Android on Mac OSX host

cmake -DCMAKE_TOOLCHAIN_FILE="`pwd`/../CMake/toolchain/android.toolchain.cmake" -DOGRE_DEPENDENCIES_DIR="`pwd`/../AndroidDependencies" -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 ..

See also

Favorite site

References


  1. Ogre-android_porting.pdf