android osg

James Cotton edited this page Nov 26, 2012 · 1 revision
Clone this wiki locally

Android OSG Setup

Compiling OSG for Android

These notes were developed from

http://www.openscenegraph.com/index.php/documentation/platform-specifics/android/44-building-openscenegraph-for-android-3-0-3-0-1

Create a directory android_osg. Unzip OpenSceneGraph-3.0.1.zip there.

This code was used to build OpenSceneGraph. It takes about 6 hours on a relatively fast computer.

cmake ../OpenSceneGraph-3.0.1 \
        -DOSG_BUILD_PLATFORM_ANDROID=ON \
        -DDYNAMIC_OPENTHREADS=OFF \
        -DDYNAMIC_OPENSCENEGRAPH=OFF \
        -DOSG_GL1_AVAILABLE=OFF \
        -DOSG_GL2_AVAILABLE=OFF \
        -DOSG_GL3_AVAILABLE=OFF \
        -DOSG_GLES1_AVAILABLE=OFF \
        -DOSG_GLES2_AVAILABLE=ON \
        -DOSG_GL_LIBRARY_STATIC=OFF \
        -DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF \
        -DOSG_GL_MATRICES_AVAILABLE=OFF \
        -DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF \
        -DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF \
        -DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF \
        -DANDROID_NDK=`pwd`/../android-ndk-r8b/ \
        -DANDROID_ABI="armeabi armeabi-v7a" \
        -DANDROID_PLATFORM=8 \
        -DANDROID_STL="gnustl_static" \
        -DCMAKE_INSTALL_PREFIX=`pwd`/../osg 
 
make CPPFLAGS="-DANDROID_ABI=\"armeabi armeabi-v7a\" -DANDROID_PLATFORM=8 -DANDROID_STL=\"gnustl_statici\" -DANDROID_DEBUG -DANDROID_OPTIM_NEON -DANDROID_OPTIM_ARM32 -DCMAKE_INSTALL_PREFIX=`pwd`/../osg"
 
make install

Compiling a demo application

http://forum.openscenegraph.org/viewtopic.php?t=10076

Use need to compile both the java and the native part. The native part is compiled with android-ndk. Modify the Android.mk file from in the JNI directory of the project to link against the OSG install directory. See the link above for a few other modifications to make on top of the default Android.mk. Then call android-nk to compile the native half of the application. Finally launch it from eclipse.