Reputation: 1766
I have been trying to fix this issue for weeks but I'm at the point where I dont know what to do now.
I think that some Android devices dont have enough memory to load the amount of textures, although it could be something else causing the issue, as I said I really dont know what to do with this.
There are 28 PNG's being loaded all 1024x1024 which come to a total of 4.8megs. Below is the OpenGL method for loading textures
GL10 gl = glGraphics.getGL();
int[] textureIds = new int[1];
gl.glGenTextures(1, textureIds, 0);
textureId = textureIds[0];
InputStream in = null;
try {
in = fileIO.readAsset(fileName);
Bitmap bitmap = BitmapFactory.decodeStream(in);
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
setFilters(GL10.GL_LINEAR , GL10.GL_LINEAR);
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
width = bitmap.getWidth();
height = bitmap.getHeight();
bitmap.recycle();
} catch(IOException e) {
throw new RuntimeException("Couldn't load texture '" + fileName +"'", e);
} finally {
if(in != null)
try { in.close(); } catch (IOException e) { }
}
There are no issues on my Desire HD, but on a HTC Cha Cha a lot of textures dont appear at all and on a Galaxy S two textures just appear white. The Cha Cha throws this error while loading textures
02-04 15:46:28.907: E/Adreno200-ES20(1501): override1= 0xfffffffe, override2= 0xfff *
Oddly if the Cha Cha is locked (OpenGL textures are destroyed) and then unlocked (reloaded textures) the particular textures that were not there initally are now, however different textures are now not visable.
Is this a memory issue? If so is there a way around this?
Thanks
Upvotes: 0
Views: 4609
Reputation: 473262
The correct solution is texture compression, not PNG compression. PVR-TC would get you most of what you need. At 4-bpp, you'd go down to 12MB instead of 117MB. Even just using lower bitdepth images, like RGB-565 formats, (16-bits per pixel) would cut your needs in half.
Also, you don't have to use 1024x1024 textures for phones; that's kind of overkill. You could probably get away with 512x512 images. Coupled with PVR-TC, you'd only need about 3MB for all of that texture data.
Upvotes: 1