什么是OPenGL ES ,我们为什么要关注它
OpenGL ES 是OpenGL的子集,它是一个3D绘图编程的标准。他尤其适用于移动设备和嵌入式设备。它属于Khronos集团,Khronos集团包括了ATI,NVIDIA和Intel等公司,这些公司共同定义和扩展了OPenGL标准。
说起OPenGL ES,它现在有3个版本:OPenG1.0,OpenG1.1,OpenG2.0。本书只是用前两个版本。所有的Android设备都支持OpenGL1.0,大多数支持OpenGL1.1。1.1版本在1.0的基础上新添加了一些功能。然而,OPenGL2.0打破了和OPenGL1.x版本的兼容性。你可以单独是用1.x或者2.0版本,但是不能同时是用他们。原因是1.x版本是用了一个叫 fixed-function pipeline的编程模型,2.0允许你通过所谓的shaders,在用程序上定义rendering pipeline。许多第二代设备已经支持OpenGL ES2.0了;然而当前在JAVA包中不能很好的使用它(除非使用Android 2.3版本)。OpenGL ES 1.x已经足够大多数的游戏使用了,所以在本书中我们会坚持使用OpenGL1.0。
NOTE: 模拟器只支持OpenGL ES 1.0,而且效果不是怎么好,所以不要在模拟器上调试你的程序。使用一个真正的设备来调试。
OpenGL ES 是一个由Khronos集团提供的C语言头文件集合,拥有一个非常复杂的书名书,说明这些头文件在API中的功能。比如说点和线是如何被绘制的。硬件制造商得到这些说明书以后,就按照要求把这些功能集成到设备的CPU驱动中。不同造商生产的设备的OPenGL ES性能会有一些区别。有些公司会严格按照标准,但有一些公司不是,这就是一些图形处理BUG产生的原因,在Android开发过程中我们对这些BUG无能为力,这些BUG的产生是硬件制造商的原因。我会在接下来的内容中指出一些设备在OpenGL ES上的特性问题。
NOTE: OpenGL ES 或多或少可以看做功能强大的OpenGL标准的兄弟。它与后者的不同之处在于它的有些功能被减弱或者已经被移除了。然而OpenGL ES可以兼容OpenGL,所以你的应用也能够很方便的移植为桌面应用。
OpenGL ES能干些什么?一个简短的回答就是它是一个倾斜和性能普通的三维绘图机器。更长的答案就有点复杂了。
附上原文:
What Is OpenGL ES and Why Should I Care?
OpenGL ES is an industry standard for (3D) graphics programming. It is especially
targeted at mobile and embedded devices. It is maintained by the Khronos Group,
which is a conglomerate of companies including ATI, NVIDIA, and Intel, who together
define and extend the standard.
Speaking of standards, there are currently three incremental versions of OpenGL ES: 1.0,
1.1, and 2.0. The first two are the ones we are concerned with in this book. All Android
devices support OpenGL ES 1.0, and most also support 1.1, which adds some new
features to the 1.0 specification. OpenGL ES 2.0, however, breaks compatibility with the
1.x versions. You can use either 1.x or 2.0, but not both at the same time. The reason for
this is that the 1.x versions use a programming model called fixed-function pipeline, while
2.0 lets you programmatically define parts of the rendering pipeline via so-called shaders.
Many of the second-generation devices already support OpenGL ES 2.0; however, the
Java bindings are currently not in a usable state (unless you target the new Android 2.3).
OpenGL ES 1.x is more than good enough for most games, though, so we will stick to it
here.
NOTE: The emulator only supports OpenGL ES 1.0. The implementation is a little shoddy, though,
so never rely on the emulator for testing. Use a real device.
OpenGL ES is an API that comes in the form of a set of C header files provided by the
Khronos group, along with a very detailed specification of how the API defined in those
headers should behave. This includes things such as how pixels and lines have to be
rendered. Hardware manufacturers then take this specification and implement it for their
GPU on top of the GPU driver. The quality of these implementations varies a little; some
companies strictly adhere to the standard (PowerVR) while others seem to have difficulty
sticking to the standard. This can sometimes result in GPU-dependent bugs in the implementation
that have nothing to do with Android itself, but with the hardware drivers
provided by the manufacturers. I’ll point out any device-specific issues along our way
into OpenGL ES land.
NOTE: OpenGL ES is more or less a sibling of the more feature-rich desktop OpenGL standard. It
deviates from the latter in that some of the functionality is reduced or completely removed.
Nevertheless, it is possible to write an application that can run with both specifications, which is
great if you want to port your game to the desktop as well.
So what does OpenGL ES actually do? The short answer is that’s it’s a lean and mean
triangle-rendering machine. The long answer is a little bit more involved.