I have a problem. So I just put my first game on Google Play. It’s a simple bridge building game.
Myself I have Samsung Galaxy S Plus running on Android 2.3.6. The game worked well on my phone, Sony Xperia Ray, HTC Gratia and Samsung Ace.
After putting my game on the market I got few responses telling me that players see nothing but white boxes which means textures don’t work for some reason. These phones were LG Optimus Black and Samsung Galaxy S running on 4.0.4. So Android 4.0.4 is custom for Samsung Galaxy S because they didn’t release official one.
What to do? All my images are 24 bit PNG and all are power of 2.
Here’s how I load them:
/** @return texture ID
*/
public int loadTexture(int resource)
{
int[] temp = new int[1];
gl.glGenTextures(1, temp, 0);
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),
resource);
gl.glBindTexture(GL10.GL_TEXTURE_2D, temp[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
// recycle the bitmap
bitmap.recycle();
return temp[0];
}
And here’s the link: https://play.google.com/store/apps/details?id=com.fizzicsgames.trainthemtocrosslite
Oh, I’m so stupid. So the problem was caused by placing textures in drawable folder instead of drawable-nodpi. Textures worked correcly on MDPI devices and on devices which support non power of 2 textures (like my Galaxy S Plus). Even though textures were power of 2, they got scaled depending on the screen. So always place your textures in drawable-nodpi if you don’t want to create a copy for each of the resolutions.