Pro Android with Kotlin


CHAPTER 9: User Interface


Download 5.42 Mb.
Pdf ko'rish
bet181/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   177   178   179   180   181   182   183   184   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile



219
CHAPTER 9: User Interface
drawListBuffer.capacity() *
BYTES_PER_SHORT,
drawListBuffer, GLES20.GL_STATIC_DRAW)
GLES20.glBindBuffer(
GLES20.GL_ARRAY_BUFFER, 0);
GLES20.glBindBuffer(
GLES20.GL_ELEMENT_ARRAY_BUFFER, 0)
} else {
//TODO: some error handling
}
}
The draw() method performs the rendering, as is the case for the triangle class we
described earlier.
fun draw() {
// Add program to OpenGL ES environment
GLES20.glUseProgram(program!!)
// Get handle to fragment shader's vColor member
colorHandle = GLES20.glGetUniformLocation(
program!!, "vColor")
// Set color for drawing the quad
GLES20.glUniform4fv(colorHandle!!, 1, color, 0)
// Get handle to vertex shader's vPosition member
positionHandle = GLES20.glGetAttribLocation(
program!!, "vPosition")
// Enable a handle to the vertices
GLES20.glEnableVertexAttribArray(
positionHandle!!)
// Prepare the coordinate data
GLES20.glVertexAttribPointer(positionHandle!!,
COORDS_PER_VERTEX,
GLES20.GL_FLOAT, false,
VERTEX_STRIDE, vertexBuffer)
// Draw the quad
GLES20.glBindBuffer(
GLES20.GL_ARRAY_BUFFER, vbo[0]);
// Bind Attributes
GLES20.glBindBuffer(
GLES20.GL_ELEMENT_ARRAY_BUFFER, ibo[0])
GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP,
drawListBuffer.capacity(),
GLES20.GL_UNSIGNED_SHORT, 0)



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   177   178   179   180   181   182   183   184   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling