0

我对android编程很陌生,正在尝试创建四边形。我使用了基本的 drawarray 代码,但它的速度不够快,无法满足我的需要。我目前拥有的是这样的:

private void drawTriangle(final FloatBuffer aTriangleBuffer, final CharBuffer indices)
{       
    GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
            0, aTriangleBuffer);        

    GLES20.glEnableVertexAttribArray(mPositionHandle);        


    // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
    // (which currently contains model * view).
    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mModelMatrix, 0);


    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, 6, GLES20.GL_UNSIGNED_BYTE, indices);                               
}

缓冲区的内容是:

final float[] vertices = {
    0.f, 0.0f, 0.0f, 

    0.05f, 0.f, 0.0f,

    0.05f, 0.0459770115f, 0.0f,

    0.0f, 0.0459770115f, 0.0f};

final char indices[] = {0,1,2,
    0,2,3
};

在此先感谢您,如果您需要任何信息,请告诉我,以便我将其包含在内。

4

0 回答 0