The GLSurfaceView is a special view which manages OpenGL surfaces for us and draws it into the Android view system.
GLSurfaceView還包括的功能:
(1) It provides a dedicated render thread for OpenGL so that the main thread is not stalled
(2) It supports continuous or on-demand rendering.
(3) It takes care of the screen setup for you using EGL, the interface between OpenGL and the underlying window system.
OpenGL中的一些術(shù)語
VBO:vertex buffer object,頂點數(shù)據(jù)
PBO:Pixel buffer object,像素數(shù)據(jù),紋理傳遞
采用DMA技術(shù),無需CPU介入
VAO:vertex array object
3.0版本以上才可使用
把對象信息直接存儲在圖形卡中,而不是在需要的時候傳輸?shù)綀D形卡。
NDC:Normalized Device Coordinates
FBO:Frame Buffer Object
LOD:Level of details
LOD技術(shù)指根據(jù)物體模型的節(jié)點在顯示環(huán)境中所處的位置和重要度,決定物體渲染的資源分配,降低非重要物體的面數(shù)和細節(jié)度,從而獲得高效率的渲染運算。
Color/Depth/Stencil Buffer
Scissor Box
Blending
MSAA/SSAA: Multisampling anti-aliasing/super sampling anti-aliasing
多重采樣抗鋸齒 ?超級采樣抗鋸齒
一般情況下MSAA比SSAA更有效,更節(jié)省資源
Vertex Shader
處理變換及光照
Fragment Shader
處理Texture Environment & Color Sum & Fog & Alpha Test
一些API
創(chuàng)建VBO
1,使用glGenBuffers()生成新緩存對象
在服務(wù)端創(chuàng)建緩存對象,并返回緩存對象的ID
2,使用glBindBuffer()綁定緩存對象
GL_ARRAY_BUFFER:任何頂點屬性,如頂點坐標(biāo)、紋理坐標(biāo)、法線及顏色分量數(shù)組
GL_ELEMENT_BUFFER:頂點的索引數(shù)據(jù)
若為0,則關(guān)閉該數(shù)據(jù)
將緩存對象連接到相應(yīng)的緩存上,同時根據(jù)target確定緩存對象最有效的位置。
3,使用glBufferData()將頂點數(shù)據(jù)拷貝到緩存對象中
將數(shù)據(jù)拷貝到緩存對象,無數(shù)據(jù)拷貝,根據(jù)size申請分配內(nèi)存
glBufferSubData()
部分數(shù)據(jù)拷貝到混存對象
glDeleteBuffers()
刪除緩存對象
修改緩存對象
(1)直接使用glBufferData()/glBufferSubData()
(2)將緩存對象映射到客戶端內(nèi)存,具體API有
glMapBuffer():將緩存對象綁定到客戶端內(nèi)存,成功則返回指向客戶端內(nèi)存的指針,否則返回NULL,會引起同步問題
glUnmapBuffer()
glGetUniformLocation()
http://ask.csdn.net/questions/11006
Shader與Program的區(qū)別與聯(lián)系
Shader范圍更大
OpenGL中,采用右手坐標(biāo)系,且矩陣按照列優(yōu)先存儲
EGL
(1)EGLDisplay
調(diào)用eglGetDisplay();
(2)initialize egl
eglInitialize(display, &majorVersion, &minorVersion);
(3) get configs
eglGetConfigs(display, ...)
(4) choose config
eglChooseConfig()
(5) create a surface
eglCreateWindowSurface()
得到EGLSurface
(6) create gl context
eglCreateContext()
(7) make the context current
eglMakeCurrent()
(8) swap buffer
eglSwapBuffers(eglDisplay, eglSurface)
EGLSurface
EGLContext
EGLNativeWindow