title OpenGL ES 3.0 DrawTriangle
Java->JNI:(1)Java_com_oyp_openglesdemo_render_MyNativeRenderer_nativeSetRenderType(100, 100)
Java->MyGLRenderContext:GetInstance()
Java->MyGLRenderContext:SetRenderType(100)
note right of NativeTriangle: GLBaseSample
MyGLRenderContext->NativeTriangle:New NativeTriangle()
Java->JNI:(2)Java_com_oyp_openglesdemo_render_MyNativeRenderer_nativeSurfaceCreate(assetManager)
Java->MyGLRenderContext:OnSurfaceCreated(assetManager)
MyGLRenderContext->GLUtils:setEnvAndAssetManager(assetManager)
MyGLRenderContext->NativeTriangle:Create NativeTriangle(m_pCurSample)
NativeTriangle->GLUtils:openTextFile(VERTEX_SHADER)
NativeTriangle->GLUtils:openTextFile(FRAGMENT_SHADER)
NativeTriangle->GLUtils:createProgram(&VERTEX_SHADER, &FRAGMENT_SHADER)
note right of NativeTriangle
loadShader(GL_VERTEX_SHADER)
loadShader(GL_FRAGMENT_SHADER)
glCreateProgram(program)
glAttachShader(program, vertexShader)
glAttachShader(program, fragmentShader)
glLinkProgram(program)
glDeleteShader(vertexShader)
glDeleteShader(fragmentShader)
end note
NativeTriangle->NativeTriangle:glClearColor(R1.0f, G1.0f, B1.0f, Alpha0.0f)
Java->JNI:(3)Java_com_oyp_openglesdemo_render_MyNativeRenderer_nativeSurfaceChange(width, height)
Java->MyGLRenderContext:OnSurfaceChanged(width, height)
MyGLRenderContext->GLBaseSample:Change(width, height)
GLBaseSample->GLBaseSample:glViewport(0, 0, width, height)
Java->JNI:(4)Java_com_oyp_openglesdemo_render_MyNativeRenderer_nativeDrawFrame()
Java->MyGLRenderContext:OnDrawFrame()
MyGLRenderContext->NativeTriangle:Draw()
NativeTriangle->NativeTriangle: glClear(GL_COLOR_BUFFER_BIT)
NativeTriangle->NativeTriangle: glUseProgram(m_ProgramObj);
NativeTriangle->NativeTriangle: glVertexAttribPointer(VERTEX_POS_INDX, 3, GL_FLOAT, GL_FALSE, 0, vVertices)
NativeTriangle->NativeTriangle: glEnableVertexAttribArray(VERTEX_POS_INDX)
NativeTriangle->NativeTriangle: glDrawArrays(GL_TRIANGLES, 0, 3)
NativeTriangle->NativeTriangle: glDisableVertexAttribArray(0)
标签:MyGLRenderContext,NativeTriangle,Java,OpenGl,VERTEX,SHADER,3.0,Android,GL From: https://www.cnblogs.com/awiki/p/17891234.html