什麼是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.