编写使用JOGL和Android的OpenGL便携式Java应用程序应用程序、Android、JOGL、Java

2023-09-04 13:27:24 作者:漫漫人生路、总会错几步

我计划写一个Java 3D游戏,将工作无论在PC和Android。不幸的是,它看起来像有两个平台没有共同的OpenGL API。

I plan on writing a Java 3D game that will work both on PC and Android. Unfortunately it looks like there is no common OpenGL API for both platforms.

执行的API显著有什么不同?有没有一种方法,我可以用相同的3D code两个版本?这是个好主意吗?

Do the APIs differ significantly? Is there a way I could use the same 3D code in both versions? Is it a good idea?

推荐答案

Android支持的OpenGL ES 1.0它使用OpenGL 1.3重叠,所以这应该是可能的,但它不是简单一个刚刚替换JAR文件在运行时。

Android supports OpenGL ES 1.0 which overlaps with OpenGL 1.3 so this should be possible, but it is not as simple a just replacing the jar files at runtime.

这是一个好主意,尝试重用尽可能多的,你在两个平台的应用。 反正它总体上是好的做法来隔离你休息code来自外部的依赖性,OpenGL的,即使你没有特别需要OpenGL ES的支持。你永远不知道什么API /平台,你可能想将您的应用程序在未来。

It is a good idea to try to reuse as much as possible of you application across both platforms. Anyway it is generally good practice to isolate the rest of you code from external dependencies such OpenGL even if you don't specifically need OpenGL ES support. You never know what API/platform you may want to port your application to in the future.

有2个选项可用。

首先是隐藏的应用程序使用的休息,然后提供独立的JOGL和Androide实现界面背后的OpenGL实现。然后根据您在您运行的平台,可以选择使用工厂模式来实例化正确的实行在运行时。

The first is to hide the OpenGL implementation behind an interface that the rest of your application uses and then provide separate Jogl and Androide implementations. Depending on which platform you are running on you can then choose to instanciate the correct implemenation at runtime using the factory pattern.

作为的OpenGL ES和OpenGL都非常相似,保持这个应该不会太高,提供你坚持的常用功能所需的工作。

As OpenGL ES and OpenGL are very similar the effort required to maintain this should not be too high providing you stick to the common functions.

另一种选择是尝试使用Jogl2这对配置文件的支持。这些似乎提供正是你需要的,但Jogl2仍处于测试阶段。

The other option is to try and use Jogl2 which has support for profiles. These appear to provide exactly what you need but Jogl2 is still in beta.

底部此页面谈了一些关于配置文件: http://kenai.com/projects/jogl/pages/FAQ

The bottom this page talks a little about profiles: http://kenai.com/projects/jogl/pages/FAQ

配置文件允许Java应用程序被写入的方式,允许具有多个版本的OpenGL同时兼容性。由于OpenGL ES的(GL为嵌入式系统)已与OpenGL的自身重叠的功能,它打开了机会增加,甚至个人档案该桥桌面和嵌入式实现。

Profiles allow Java applications to be written in a way which allows compatibility with multiple OpenGL versions at the same time. Since OpenGL ES (GL for embedded systems) has overlapping functionality with OpenGL itself it opened the opportunity to add even Profiles which bridge desktop and embedded implementations.

您可能需要阅读本http://michael-bien.com/mbien/entry/jogl_2_opengl_profiles_explained有关配置文件的详细信息。

You might want to read this http://michael-bien.com/mbien/entry/jogl_2_opengl_profiles_explained for more information about profiles.

 
精彩推荐
图片推荐