我正在开发一款简单的乒乓球游戏来掌握opengl和android,并且在性能方面似乎已经打了一堵砖墙.
我的游戏逻辑在一个单独的线程上,draw命令通过阻塞队列发送到gl线程.问题是我被困在40fps左右,我尝试过的任何东西似乎都没有提高帧速率.
为了简单起见,我设置了opengl:
GLES20.glDisable(GLES20.GL_CULL_FACE);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glDisable(GLES20.GL_BLEND);
Run Code Online (Sandbox Code Playgroud)
设置opengl程序和绘图由以下类处理:
class GLRectangle {
private final String vertexShaderCode =
"precision lowp float;" +
// This matrix member variable provides a hook to manipulate
// the coordinates of the objects that use this vertex shader
"uniform lowp mat4 uMVPMatrix;" +
"attribute lowp vec4 vPosition;" +
"void main() {" +
// the matrix must be included as a modifier of gl_Position
" gl_Position = vPosition * uMVPMatrix;" +
"}";
private final String fragmentShaderCode =
"precision lowp …Run Code Online (Sandbox Code Playgroud)