---Init---
Code: Select all
glCreateShader() => vertShader
glShaderSource(vertShader, vertSource)
glCompileShader(vertShader)
glCreateShader() => fragShader
glShaderSource(fragShader, fragSource)
glCompileShader(fragShader)
glCreateProgram() => program
glAttachShader(program, vertShader)
glAttachShader(program, fragShader)
glBindAttribLocation(program, attribLoc0, attribName0)
...
glBindAttribLocation(program, attribLocN, attribNameN)
glLinkProgram(program)
glGetUniformLocation(program, unifName0) => unifLoc0
...
glGetUniformLocation(program, unifNameN) => unifLocN
Code: Select all
glBindBuffer(GL_ARRAY_BUFFER, vtxBuffer)
glVertexAttribPointer(attribLoc0, ...)
glEnableVertexAttribArray(attribLoc0)
...
glVertexAttribPointer(attribLocN, ...)
glEnableVertexAttribArray(attribLocN)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idxBuffer)
glUseProgram(program)
glUniform*(unifLoc0, unifValue0)
...
glUniform*(unifLocN, unifValueN)
glDrawElements(...)
OpenGL ES 2.0 API Reference (khronos.org)
Vertex Shader Attribute Mapping in GLSL (stackoverflow.com)