有没有办法处理不同形状(顶点数组)的渲染顺序?
绿色平面应该在蓝色平面的前面:
override fun onDrawFrame(unused: GL10) {
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT)
Matrix.setLookAtM(
view,
0,
eyeValue.x, eyeValue.y, eyeValue.z,
0f, 0f, 0f,
0f, 1.0f, 0.0f
)
Matrix.multiplyMM(mvp, 0, projection, 0, view, 0)
shapes.forEach {
it.onDraw(mvp)
}
}
open fun onDraw(mvp: FloatArray) {
program.onDrawStart()
program.setV4(uNames.uColor, arrayColor)
program.setV4Matrix(uNames.uMvp, mvp)
program.drawVertexes(vertexes.buffer)
}
您必须启用Depth Test: