形状的渲染顺序

问题描述 投票:2回答:1

有没有办法处理不同形状(顶点数组)的渲染顺序?

绿色平面应该在蓝色平面的前面:

enter image description here

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)
}
android opengl-es glsl opengl-es-2.0
1个回答
1
投票

您必须启用Depth Test

© www.soinside.com 2019 - 2024. All rights reserved.