我正在使用OpenGL ES 2开发一个Android应用程序.我遇到的问题是该glClear()功能需要很长时间才能处理,因为帧延迟会导致游戏显得紧张.具有定时探针的程序运行的输出显示,虽然设置来自图集的所有顶点和图像仅需要不到1毫秒,但glClear()需要10到20毫秒.事实上,清算通常占总渲染时间的95%.我的代码基于常见教程,Render功能如下:
private void Render(float[] m, short[] indices) {
Log.d("time", "--START RENDER--");
// get handle to vertex shader's vPosition member
int mPositionHandle = GLES20.glGetAttribLocation(riGraphicTools.sp_Image, "vPosition");
// Enable generic vertex attribute array
GLES20.glEnableVertexAttribArray(mPositionHandle);
// Prepare the triangle coordinate data
GLES20.glVertexAttribPointer(mPositionHandle, 3,
GLES20.GL_FLOAT, true,
0, vertexBuffer);
// Get handle to texture coordinates location
int mTexCoordLoc = GLES20.glGetAttribLocation(riGraphicTools.sp_Image, "a_texCoord" );
// Enable generic vertex attribute array
GLES20.glEnableVertexAttribArray ( mTexCoordLoc );
// Prepare the texturecoordinates
GLES20.glVertexAttribPointer ( …Run Code Online (Sandbox Code Playgroud)