Open Graphics Library (OpenGL) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.
OpenGL是和编程语言、平台无关的一套interface ,主要是为了渲染 2D 和 3D图形等。一般这套接口是用来和GPU进行交互的,使用GPU进行硬件加速。
Android includes support for high performance 2D and 3D graphics with the Open Graphics Library (OpenGL®), specifically, the OpenGL ES API. OpenGL is a cross-platform graphics API that specifies a standard software interface for 3D graphics processing hardware. OpenGL ES is a flavor of the OpenGL specification intended for embedded devices.
OpenGL ES就是专为嵌入式设备设计的,OpenGL ES和OpenGL中的函数接口有一些是不一样,因为嵌入式设备和pc等的硬件处理能力有差距的。
既然OpenGL ES只是一组函数接口,Android平台提供了两种类型的实现:软件实现,硬件实现。
a.硬件实现,前面提到这组函数接口主要是为了和GPU这个硬件进行打交道的。所以各个硬件厂商会提供相关的实现,例如高通平台的adreno解决方案;
b.软件实现,Android自身也提供了一套OpenGL ES的软件实现,不使用GPU,完全用软件实现画图的相关功能,也就是libagl
EGL - Native Platform Interface
EGL? is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system.
It handles graphics context management, surface/buffer binding, and rendering synchronization and enables high-performance, accelerated, mixed-mode 2D and 3D rendering using other Khronos APIs.
那么什么是EGL?EGL是OpenGL ES和底层的native window system之间的接口,承上启下。
EGL is a complement to OpenGL ES. EGL is used for getting surfaces to render to using functions like eglCreateWindowSurface, and you can then draw to that surface with OpenGL ES. Its role is similar to GLX/WGL/CGL.
Whether or not EGL can give you a context that supports OpenGL ES 2.0 may vary by platform, but if the Android device supports ES 2.0 and EGL, you should be able to get such a context from EGL. Take a look at the EGL_RENDERABLE_TYPE attribute and the EGL_OPENGL_ES2_BIT when requesting an EGLConfig.
http://www.khronos.org/files/egl-1-4-quick-reference-card.pdf
在Android上,EGL完善了OpenGL ES。利用类似eglCreateWindowSurface的EGL函数可以创建surface 用来render ,有了这个surface就能往这个surface中利用OpenGL ES函数去画图。
下图表示的是显示相关的几个模块的关系,
其中FrameBufferNativeWindow已经过时。通过该图可以看到EGL OpenGL所处的位置。
MTK:
so | directory | descrption |
---|---|---|
libEGL_mtk.so | /vendor/lib/egl /vendor/lib64/egl | egl的实现 |
libGLESv1_CM.so libGLESv2.so | /vendor/lib/egl /vendor/lib64/egl | opengl具体实现的wrapper |
libGLES_android.so | /system/lib/egl /system/lib64/egl | opengl软件实现,即agl |
libGLESv1_CM_mtk.so libGLESv2_mtk.so | /vendor/lib/egl /vendor/lib64/egl | opengl硬件实现,即hgl |
高通:
so | directory | descrption |
---|---|---|
egl.cfg | /system/lib/egl | 选择图形渲染方式(libagl/libhgl) |
libEGL_adreno.so | /vendor/lib/egl /vendor/lib64/egl | egl的实现 |
libGLES_android.so | /system/lib/egl /system/lib64/egl | opengl软件实现,即agl |
libGLESv1_CM_adreno.so libGLESv2_adreno.so | /vendor/lib/egl /vendor/lib64/egl | opengl硬件实现,即hgl |
本文参考文章: EGL和OpenGL ES之间的关系
另外强烈推荐两篇讲解agl的文章:
http://blog.csdn.net/happy19850920/article/details/50673005
http://blog.csdn.net/happy19850920/article/details/50773875