09-27
2016
龙芯3A2000上移植NASA WorldWind指南
一、初识NASA WORLDWIND
NASA World Wind是NASA出品,类似Earthview 3D的鸟瞰工具,更加权威而且完全免费。通过这套程序的3D引擎,可以让你从外太空看见地球上的任何一个角落。
worldwind主界面
有“天眼”之称的一款软件是否可以在龙芯平台上运行呢?经过修改、调试、编译,笔者终于成功的在龙芯3A2000上运行了worldwind。下面来看看移植过程。二、下载worldwind以及相关的软件包
首先介绍下和worliwind相关的两外两个软件包gluegen和jogl。
gluegen是自动生成的java和JNI代码,调用C库的工具,可以绑定底层API,如java本地接口(JNI)和 AWT本地接口(jawt)。
jogl是Java对OpenGL绑定的开源项目并设计为采用Java开发的应用程序,还提供了众多3D图形库,如:AWT、Swing和SWT widget,以及自定义窗口工具nativewindow。
为了不让大家走弯路,笔者先简单的介绍下载包的版本。笔者下载的worldwind是2.0.0版本,REDME.txt文档上介绍支持Java SDK1.5.0以上版本。需下载1.5版本的gluegen和jogl包。
● worldwind下载路径:http://ftp.loongnix.org/others/NasaWorldWind/

点击gluegen-v2.1.5.tar.7z和jogl-v2.1.5.tar.7z即可下载。

笔者使用的电脑是龙芯3A2000,系统是Loongnix-Fedora21。
系统下载地址: http://www.loongnix.org
四、编译源代码
笔者详细的述说这三个软件包里需要修改的地方。
第一步:首先编译gluegen软件包
1.进入gluegen软件包,查找build.xml文件。(记得将解压后的文件名修改为gluegen)
[loongson@localhost gluegen]$find . -name build.xml ./test/TestOneJar_InJar/jogamp01/build.xml ./test/junit/com/jogamp/gluegen/build.xml ./make/build.xml |
在328行添加如下代码:
+ + + + + |
+ declare.linux.mips64el, |
[loongson@localhost gluegen]$ find . -name PlatformPropsImpl.java ./src/java/jogamp/common/os/PlatformPropsImpl.java |
+ else if( archLower.equals("mips64") ) { // android gaoquan + return CPUType.MIPS_64; + } else if( archLower.equals("mips64el") ) { // android gaoquan + return CPUType.MIPS_64el; + } |
在./src/java/jogamp/common/os/PlatformPropsImpl.java文件的getOSAndArch()方法下,添加分支,代码如下:
case IA64: _os_and_arch = "ia64"; break; + case MIPS_64el: + os_and_arch = "mips64el"; + break; case SPARCV9_64: _os_and_arch = "sparcv9"; break; |
在./src/java/jogamp/common/os/MachineDescriptionRuntime.java文件的isCPUArch32Bit()方法下,添加分支,代码如下:
private static boolean isCPUArch32Bit(final Platform.CPUType cpuType) throws RuntimeException { switch( cpuType ) { case X86_32: ........... + case MIPS_64el: return false; |
在gluegen-cpptasks-base.xml中搜索mipsel,在380行添加代码:
+ + + + + + + + + + + + |
+ |
+ + + |
+ gluegen.cpptasks.detect.os.linux.mips64el, |
+ + |
+ + + + + + |
+ gluegen.cpptasks.declare.compiler.linux.mipsel, |
+ + + |
gluegen.build.check.aapt: android.package: developer-src-zip: [zip] Building zip: /home/loongson/jogl/gluegen/build/gluegen-java-src.zip developer-zip-archive: all: BUILD SUCCESSFUL |
* 最后记得将build目录下的 .jar 文件拷贝到worldwind下
第二步:编译jogl软件包
1.下载swt.jar文件(http://ftp.loongnix.org/others/NasaWorldWind/),拷贝到swt目录下(jogl-v2.1.5/make/lib/swt/)
2.进入jogl-v2.15软件包,在./make/build-nativewindow.xml文件中进行修改。
+ + + + + .......... + c.configure.linux.mipsel,c.configure.linux.mips64el,c.configure.linux.ppc |
+ + + |
+ + + + + + c.configure.linux.mipsel,c.configure.linux.mips64el,c.configure.linux.ppc |
+ + + + + + + + + c.configure.linux.mipsel,c.configure.linux.mips64el,c.configure.linux.ppc |
all: BUILD SUCCESSFUL Total time: 3 minutes 1 second |
* 记得将jogl下的jogl-all.jar、nativewindow-natives-linux-mips64el.jar、jogl-all-natives-linux-mips64el.jar,拷贝到worldwind下
第三步:在worldwind下,运行提供的用例。
[loongson@localhost worldwind-2.0.0]$ chmod +x run-demo.bash [loongson@localhost worldwind-2.0.0]$ ./run-demo.bash gov.nasa.worldwindx.examples.ApplicationTemplate |
为了能够更流畅的查看地图,可以屏蔽终端的输入:
[loongson@localhost worldwind-2.0.0]$ ./run-demo.bash gov.nasa.worldwindx.examples.ApplicationTemplate &>/dev/null |

1000km高空下的地球

北京城市地图

龙芯公司

华盛顿城市路线图
worldwind官方网站上提供更多精美实例,大家一起欣赏下。


五、如果您觉得要修改的代码太多,不方便。笔者为你提供了更简单的方法。
1. 下载http://ftp.loongnix.org/others/NasaWorldWind/ 里面有patch文件,还有使用说明。根据说明来修改三个软件包,最后在worldwind目录里输入
./run-demo.bash gov.nasa.worldwindx.examples.ApplicationTemplate