i have implemented a tile based layer in my game, but after the first time that it was drawn, just the first time i try to update it (to add tiny decals, like blood splats, craters, etc. thingies that are added to the map and that i don't want to draw separately every loop) i have a huge hiccup of 3~ seconds.
after some test, i have find the only call that hangs.
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, x, y, width, height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer);
the decal is really tiny(32 * 32 pixel), there is no opengl error after this call, and i really don't get the whole thing (i mean.....the creation of the whole tile layer actually takes much lesser than 1 second, and is done by a thousand of glTexSubImage2D command on a large blank texture.....3 seconds is pretty huge).
i already have a workaround (a "fake" update just before the splash screen goes off) but i really want to understand this odd(for me, at least) behaviour.. :|
(i'm deeply sorry for my enGrish, i hope that's understandable)
METHOD:
public static void replaceSubImg(GL10 gl, int hwdId , int x,int y,int width, int height,Buffer pixelBuffer) {
gl.glFinish();
gl.glBindTexture(GL10.GL_TEXTURE_2D, hwdId);
long time = System.currentTimeMillis();
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, x, y, width, height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer);
Log.d("testApps","openglUtil,@@@@@@@@@@@@@@@@@@@@@@@@@ subImg replaced in "+(System.currentTimeMillis()-time)+" ms");
}
LOG:
DEBUG/testApps(3809): openglUtil,@@@@@@@@@@@@@@@@@@@@@@@@@ subImg replaced in 2811 ms
DEBUG/testApps(3809): openglUtil,@@@@@@@@@@@@@@@@@@@@@@@@@ subImg replaced in 1 ms(this is the 2d run)