在Android上编译OSG[3.0.2 ]

分类:Android
 

This file contents can be 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 you'll also need the Android SDK

The required version to compile OSG is 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 use Android 2.1 devices succesfully but it's not recommended. Older Android versions are not supported. There are specific device models with a bug that 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 you have to use the macros: USE_OSGPLUGIN(),USE_DOTOSGWRAPPER_LIBRARY(),USE_SERIALIZER_WRAPPER_LIBRARY().
  • OSG for Android uses OpenGL ES 1.X/2.0.
    • There are features present in OpenGL that doesn't exist in OpenGL ES: http://www.khronos.org/opengles/
    • ENVIRONMENTAL MAPPING DOESN'T WORK but  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 will 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 are the variables that have to be set.

ANDROID BUILD

The first CMake variable to be set is the Android build Variable

-DOSG_BUILD_PLATFORM_ANDROID=ON

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

-DANDROID_NDK={Path to your NDK root directory}

Right now, Android version has to be compiled in static. To do so you have to set the next variables.

-DDYNAMIC_OPENTHREADS=OFF
-DDYNAMIC_OPENSCENEGRAPH=OFF

OPENGL ES CONFIG

When working in Android, you have to set OSG in GLES1 OR GLES2 configuration. It's not advisable to compile with support for both at the same time. Runtime linking error may happen. To set GLES1/2 functionality you have to set 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=ON

GLES2

-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

COMPILATION OPTIONS

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

-DANDROID_ABI "armeabi armeabi-v7a"
-DANDROID_PLATFORM=8

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

-DANDROID_STL="gnustl_static"

To generate the binary libraries with debug symbols you have to use the next variable.

-DANDROID_DEBUG

OPTIMIZATIONS

The next variables can be set to true to enable some optimizations. Beware that not all devices are compatible with them and not on all ABI platforms.

-DANDROID_OPTIM_NEON
-DANDROID_OPTIM_ARM32

OTHERS

To enable the -j command  you have to set it in the Cmake line.

-DJ=4

To define a install path you have to use the nex variable

-DCMAKE_INSTALL_PREFIX={install path}

Building your application

Building an application in Android withouth any prior knowledge is hard. If you don't have 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

ANDROID

  • Reto Meier Professional Android 4 Application Development
  • Sylvain Ratabouil Android NDK

Building an application with a native part in Android is a two step job. First you have to compile the native part with the ndk-build and second you need to compile the java part. There are some plugins in eclipse that ease this part like  Sequoyah. If you want to check how to do a OsgAndroid Application then there are two examples in the OSG distribution. They are for GLES1 and GLES2. This are 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 are 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 is a 3rd party dependency pack with libjpeg, libpng, libtiff, libcurl and freetype to use with OpenSceneGraph in Android. This pack 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 will be detected and configured appropiatedly.

点击数:1098

在Android上编译OSG[3.0.2 ] (转)的更多相关文章

  1. 在Linux上编译Hadoop-2.4.0

    目录 目录 1 1. 前言 1 2. 安装依赖 1 2.1. 安装ProtocolBuffer 2 2.2. 安装CMake 2 2.3. 安装JDK 2 2.4. 安装Maven 3 3. 编译Ha ...

  2. CentOS 64位上编译 Hadoop2.6.0

    由于hadoop-2.6.0.tar.gz安装包是在32位机器上编译的,64位的机器加载本地库.so文件时会出错,比如: java.lang.UnsatisfiedLinkError: org.apa ...

  3. 在Linux上编译Hadoop-2.4.0实践与总结

    问题导读: 1.编译源码前需要安装哪些软件? 2.安装之后该如何设置环境变量? 3.为什么不要使用JDK1.8? 4.mvn package -Pdist -DskipTests -Dtar的作用是什 ...

  4. 在干净的ubuntu 14.10上编译Qemu2.2.0的过程

    下载Qemu的源代码 从官网http://wiki.qemu.org/Main_Page 中下载最新的源代码,目前是2.2.0. 安装依赖库和编译 编译过程分两步1. ./configure 2. m ...

  5. FFmpeg在Android上的移植优化步骤

    http://blog.csdn.net/feixiang_john/article/details/7894188 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmp ...

  6. FFmpeg在Android上的移植之第一步

    http://blog.sina.com.cn/s/blog_69a04cf40100x1fr.html 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmpeg开发的. ...

  7. Yarn上运行spark-1.6.0

    目录 目录 1 1. 约定 1 2. 安装Scala 1 2.1. 下载 2 2.2. 安装 2 2.3. 设置环境变量 2 3. 安装Spark 2 3.1. 下载 2 3.2. 安装 2 3.3. ...

  8. 编译osg for android

    做osg数数已经快两年了,之前将一些opengl的代码搬到了osg上,现在将一些osg的代码搬到了android上,尝试看看效果. 首先是编译的事情,android for android在http: ...

  9. 编译可在Nexus5上运行的CyanogenMod13.0 ROM(基于Android6.0)

    编译可在Nexus5上运行的CyanogenMod13.0 ROM (基于Android6.0) 作者:寻禹@阿里聚安全 前言 下文中无特殊说明时CM代表CyanogenMod的缩写. 下文中说的“设 ...

随机推荐

  1. MYSQL学习心得(转)

    适合有SQL SERVER或ORACLE基础的人看,有对比,学习更有效果 转自:http://www.cnblogs.com/lyhabc/ 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习 ...

  2. startActivityForResult用法

    使用场景:A界面(activity) 可跳转到一个(假设为 B)或多个子Activity,要求B处理完工作之后返回A 界面,或许同时返回一些数据交给A继续处理.如 由登陆界面A跳转到注册界面B,注册成 ...

  3. sklearn快速入门

    原创博文,转载请注明出处. (为了节约空间,打印结果常用"..."表示省略) 一.加载数据集 1. 加载sklearn自带的数据集 scikit-learn有一些自带的标准数据集, ...

  4. [python][django学习篇][8]django 视图(2) --简单模板

    在视图函数里返回的是一个 HttpResponse 类的实例,我们给它传入了一个希望显示在用户浏览器上的字符串.但是我们的博客不可能只显示这么一句话,它有可能会显示很长很长的内容.比如我们发布的博客文 ...

  5. Python之基于socket和select模块实现IO多路复用

    '''IO指的是输入输出,一部分指的是文件操作,还有一部分网络传输操作,例如soekct就是其中之一:多路复用指的是利用一种机制,同时使用多个IO,例如同时监听多个文件句柄(socket对象一旦传送或 ...

  6. REDIS基础笔记

    Redis基础笔记 资源链接 简介 简介 安装 五种数据类型及相应命令 1. 字符串类型 2. 散列类型 3. 列表类型 4. 集合类型 5. 有序集合 其他 事务 SORT 生存时间 任务队列 发布 ...

  7. [CQOI2016][bzoj4519] 不同的最小割 [最小割树]

    题面 传送门 思路 首先我们明确一点:这道题不是让你把$n^2$个最小割跑一遍[废话] 但是最小割过程是必要的,因为最小割并没有别的效率更高的算法(Stoer-Wagner之类的?) 那我们就要尽量找 ...

  8. [SDOI2011][bzoj2245] 工作分配 [费用流]

    题面 传送门 思路 数据范围n,m<=250 分配任务问题 这是典型的"看到数据范围就知道算法"类型 而且我们发现我们要保证一定产出的情况下最小化花费 这句话等价于保证一定流 ...

  9. Juice Junctions

    Juice Junctions 题目描述 你被雇佣升级一个旧果汁加工厂的橙汁运输系统.系统有管道和节点构成.每条管道都是双向的,且每条管道的流量都是11升每秒.管道可能连接节点,每个节点最多可以连接3 ...

  10. 【04】Vue 之 事件处理

    4.1. 监听事件的Vue处理 Vue提供了协助我们为标签绑定时间的方法,当然我们可以直接用dom原生的方式去绑定事件.Vue提供的指令进行绑定也是非常方便,而且能让ViewModel更简洁,逻辑更彻 ...