i’m new to android programming and i’m trying to create a relatively big 2D game. I have to use lots of images and objects in my game so I decided to use OpenGL ES. I have several texture atlases, all of them saved as png’s because of the transparency. I also know, but i’m not sure why, that I have to use images, which height and width is multiple of two. I test my game on an old HTC Hero running Android 2.3.3. When my picture atlases are 512×512 each, my game has a frame rate of between 50 to 60 fps. When I use 1024×1024 non transparent png, there is no problem – the FPS is again between 50 to 60 fps. But when i decide to use a 1024×1024 transperent PNG’s my frame rate drops to 4,5 fps. Could this be a problem related to the age of the device i’m using for testing? These are the OpenGL functions I use each loop to draw batches:
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
//drawing happens here
gl.glDisable(GL10.GL_BLEND);
Thanks in advance 🙂
I think what you’re seeing is that your texture becomes to large to keep in VRAM close to the GPU, so that it has to be fetched from normal RAM and sent over the bus with every frame. From the numbers you posted the maximum usable amount is 1 MB (1024x1024x8bpp for RGB565), so you should stay well below that. You can probably switch to RGBA4444 without seeing the drop in performance. Or go 512x1024x16bpp (RGBA8888) if you need the largest size possible with 8bit colors and transparency.
PS. I wouldn’t be surprised if you also see a drop when you start using VBOs in conjunction with the 1024x1024x8bpp, as they also reside in that limited amount of RAM.