私は自分のopengl 2.0のゲームでパフォーマンスに問題があります。フレームレートは、私がゲームを変えるまでうまかった。 64種類の爆発ゲーム(レンガ)。私が今望んでいるのは、ボールが直ちに除去されないレンガに当たったときです。ステータスが変わり、テクスチャを変更するか、より正確にはアトラスのUV座標が含まれます。私はテクスチャクラスを持っており、ループの外側を呼び出すのではなく、ループ内のすべてのテクスチャに対してGLES20.bindBuffer()を呼び出すだけです。以前の私は、すべての図形の同じUV-COORDがあったが、今、私はそれはレンガのステータスに応じて変更し、私はOpenGL ES 2.0:頻繁にbindbufferを使用したパフォーマンス低下
private void drawShape() {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vboDataListLevelSprites.get(iName).getBuff_id_vertices());
GLES20.glEnableVertexAttribArray(mPositionHandle);
GLES20.glVertexAttribPointer(mPositionHandle, 3, GLES20.GL_FLOAT, false, 0, 0);
//used this snipped before when using the same image (uv-coords) for all bricks
/*GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vboDataListLevelSprites.get(iName).getBuff_id_uvs());
GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
GLES20.glVertexAttribPointer(mTextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, 0);
*/
for (Iterator<BrickProperties> it = arrayListBricks.iterator(); it.hasNext();) {
BrickProperties bp = it.next();
//now bindbuffer inside loop just too switch uv-coords of the atlas when its time to use another image
int buffIndexVal = bp.get_status_diff();
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, BrickProperties.get_buff_id_uvs()[buffIndexVal]);
GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
GLES20.glVertexAttribPointer(mTextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, 0);
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, bp.getTranslateData()[0], bp.getTranslateData()[1], bp.getTranslateData()[2]);
if (bp.get_status() == 0) {
it.remove();
}
render();
}
}
private void render() {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
}
私は、パフォーマンスの低下に理由を理解してループ内でバインディングを使用する必要がある理由thatsのすべてですGPUへのbindbuffer呼び出しが、この問題を回避する方法はありますか?
ありがとうございます - 私はこれをさらに調べます。私は問題をキャッチすると思う – java