我对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
};
提前致谢,如果您需要任何信息,请告诉我,以便我可以加入。