Compile osg[3.0.2 on Android] (go)

Source: Internet
Author: User

Compiling osg[3.0.2 on Android]
Category: Android

This file contents can is applied for version OpenSceneGraph (OSG) 3.0.2 or newer.

Prerequisites for Build process

To compile OSG as a standalone library you'll only need the Android NDK. To develop applications with the library of you ' ll also need the Android SDK

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

The required version to compile OSG is the NDK R5 or newer. We don ' t recommend using previous versions or modified versions although it ' s possible to use the Crystax NDK versions.

Device Minimun Requirements

OSG for Android need to use a level 8 or newer Native ABI and a 2.2 or newer Android version. It's possible to the use of Android 2.1 devices succesfully but it's not recommended. Older Android versions is not supported. There is specific device models with a bug which need the application locked in landscape mode to run.

OpenSceneGraph Android Known Issues
  • OSG for Android is a STATIC build library
      • To add a plugin or module that has the to use the Macros:use_osgplugin (), Use_dotosgwrapper_library (), use_serializer_wrapper_l Ibrary ().
  • OSG for Android uses OpenGL ES 1.x/2.0.
    • There is features present in OpenGL this doesn ' t exist in OpenGL es:http://www.khronos.org/opengles/
    • Environmental MAPPING doesn ' T work if you can use a E.M. Shader in GLES 2.0.
    • OSG pregenerated Shaders DON ' T compile with GLES, you need to add your Shaders.
  • Multithreaded Viewer crashes the application.
  • Osgsim and Osgshadow would crash the application if you don ' t link freetype.
Build Config

For the Android building in OSG, we use the CMake command line to generate the Android makefiles. These is the variables that has to be set.

ANDROID BUILD

The first CMake variable to BES set is the Android build variable

-dosg_build_platform_android=on

Now, CMake needs to know where you have the NDK. That ' s do by setting the next variable

-dandroid_ndk={path to your NDK root directory}

Right now, Android version have to is compiled in static. To does so, you have the to set the next variables.

-ddynamic_openthreads=off-ddynamic_openscenegraph=offOPENGL ES CONFIG

When working is on Android, you has to set OSG in GLES1 OR GLES2 configuration. It's not a advisable to compile with a both at the same time. Runtime linking error may happen. To set GLES1/2 functionality the options in CMake:

Gles1-dosg_gl1_available=off-dosg_gl2_available=off-dosg_gl3_available=off-dosg_gles1_available=on-dosg_gles2_available=off-dosg_gl_library_static=off-dosg_gl_displaylists_available=off-dosg_gl_matrices_available=on-dosg_gl_vertex_funcs_available=on-dosg_gl_vertex_array_funcs_available=on-dosg_gl_fixed_function_available=onGles2-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=offCompilation OPTIONS

You can select the Android ABI hardwares to be compiled (x86,armeabi,armeabi-v7a,mips) This option is set by default to AR Meabi armeabi-v7a and the ABI platform version. This option was set by default to 5.

-dandroid_abi "Armeabi armeabi-v7a"-dandroid_platform=8

OSG requires the C + + STL library in Android there is several different STL versions static and shared. Which Versión is used can was setted with the next variable. By default this variable is set to Gnustl_static.

-dandroid_stl= "Gnustl_static"

To generate, the binary libraries with the debug symbols and the next variable.

-dandroid_debugOptimizations

The next variables can is set to true to enable some optimizations. Beware that isn't all devices is compatible with them and is on the all ABI platforms.

-dandroid_optim_neon-dandroid_optim_arm32OTHERS

To enable THE-J command for you with the to set it on the Cmake line.

-dj=4

To define a, install path, and use the NEX variable

-dcmake_install_prefix={install path}Building your application

Building an application on Android withouth any prior knowledge are hard. If you don't have the experience developing simple test Android NDK applications don ' t try to cope with OSG in Android. First learn some basics of Android/dalvik and about ANDROID/NDK. It's not recommendable to go to our mailing lists or Google ' s withouth some knowledge first. For some good readins I can recommend the next books:

OpenSceneGraph
    • Wang Rui et Al openscenegraph Beginners Guide Published
    • Wang Rui et Al openscenegraph Cookbook Published
Android
    • reto Meier Professional Android 4 application development
    • sylvain Ratabouil Android NDK

Building an application with a native part on Android is a step job. First you has to compile the native part with the Ndk-build and second you need to compile the Java part. There is some plugins in eclipse the ease this part like Sequoyah. If you want to check how to does a osgandroid application then there is both examples in the OSG distribution. They is for GLES1 and GLES2. This is the characteristics implemented in the application.

  • Resolution Locked to landscape.
  • Menu button shows a Android menu with options to load or delete models, also you can use the virtual keyboard.
  • Basic state and Manipulator changes by keyboard entry.
  • Android UI with buttons to center view and change mode of navigation.
  • Multitouch example.
Keep in mind that the examples is not fully native. They don ' t use the nativeactivity and so they rely on a JNI code to call the OSG functions from the Java side. 3rd party Dependencies

To ease the development of applications, there are a 3rd party dependency packs with Libjpeg, libpng, Libtiff, Libcurl and F Reetype to use with OpenSceneGraph in Android.  This pack is only works with Armeabi V5 and V7. The package can be found at the next address: Http://www2.ai2.upv.es/difusion/osgAndroid/3rdpartyAndroid.zip

To use the package, put the 3rdparty directory inside the OSG root directory and run Cmake. It'll be detected and configured appropiatedly.

Hits: 1098

Compile osg[3.0.2 on Android] (go)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.