사용자가 화면을 터치하여 드래그하여 90 개의 2D 모양을 그릴 수있는 프로그램이 있습니다. 눈에 띄는 양의 choppiness가 있으며 DDMS는 가장 많은 CPU 시간 (~ 85 %)을 차지하는 한 가지 방법이 draw() 메소드라고합니다. 실제로는 하나의 모양 만 움직이고 다른 하나는 그렇지 않기 때문에 89 개의 모양을 FrameBuffer 객체를 사용하여 텍스처에 렌더링하고 전체 화면을 채우는 모양으로 그 질감을 그릴 수 있습니까? 그렇지 않다면 과속을 일으킬 다른 잠재적 인 방법이 있습니까?OpenGL ES2 : FrameBuffer 객체를 사용하여 더 많은 모양을 더 빨리 렌더링합니다.
private void draw() {
// Pass in the position information
mCubePositions.position(0);
GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false, 0, mCubePositions);
GLES20.glEnableVertexAttribArray(mPositionHandle);
// Pass in the color information
mCubeColors.position(0);
GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false, 0, mCubeColors);
GLES20.glEnableVertexAttribArray(mColorHandle);
// Pass in the texture coordinate information
mCubeTextureCoordinates.position(0);
GLES20.glVertexAttribPointer(mTextureCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false, 0, mCubeTextureCoordinates);
GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
// 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, mViewMatrix, 0, mModelMatrix, 0);
// Pass in the modelview matrix.
GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0);
// This multiplies the modelview matrix by the projection matrix, and
// stores the result in the MVP matrix
// (which now contains model * view * projection).
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
// Draw the cube.
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
}
미리 감사드립니다.
저는 S5570에서 실행됩니다. 대부분의 큐브는 매우 작으며 크기를 변경해도 프레임 속도에 큰 영향을 미치지 않습니다. 큐브의 개수, 크기 및 텍스처는 다른 큐브의 위치에 따라 크게 달라지며 사용자가 모양을 드래그 할 때마다 변경됩니다. ArrayList의 크기를 조절하고 매번 큐브가있는 배열로 변환 할 때마다 비효율적입니까? 어떻게 하나의 그리기 호출을 하나의 배열에서 개별 셰이프로 렌더링 할 수 있습니까? –
자세한 답변을 보내 주셔서 감사합니다. 그러나 한 가지 질문 :이 방법은 아니오를 허용합니까? 그려진 큐브와 아니요. 즉시 증가하거나 감소하도록 지원되는 텍스처 –
예, 최대한 많은 수의 큐브를 결정하고이 최대 값에 대한 데이터 구조를 미리 할당하여 즉시 할당하는 것을 피하는 것이 좋습니다. 예를 들어 위의 예에서 최대 16 개의 텍스처를 허용했습니다. –