views:

116

answers:

1

Hi I'm developing a game for android using OpenGL es and have hit a problem:

My game loads fine in the emulator (windows xp and vista from eclipse), it also loads fine on a T-Mobile G2 (HTC Hero) however when I load it on my new HTC Desire none of the textures appear to load correctly (or at all). I'm suspecting the BitmapFactory.decode method although I have no evidence that that is the problem.

All of my textures are power of 2 and JPG textures seem to load (although they don't look great quality) but anything that is GIF or PNG just doesn't load at all except for a 2x2 red square which loads fine and one texture that maps to a 3d object but seems to fill each triangle of the mesh with the nearest colour).

This is my code for loading images:

     AssetManager am = androidContext.getAssets();
  BufferedInputStream is = null;
  try {
     is = new BufferedInputStream(am.open(fileName));

     Bitmap bitmap;

     bitmap = BitmapFactory.decodeStream(is);

     GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
     bitmap.recycle();
  } catch(IOException e) {
     Logger.global.log(Level.SEVERE, e.getLocalizedMessage());
  } finally {
     try {
        is.close();
     } catch(Exception e) {
        // Ignore.
     }
  }

thanks

A: 

I've got the same problem. For me - it only occurs when the png has transparency. It all started happening when i upgraded to 2.2. Before textures were working fine even if they weren't power of 2.

But now it's totally random. I create a png file in GIMP with transparent backgroud. Drew some lines with brush and it shows black in Android app. Then i edited it, added 3 more lines and it loads ok. Then i did some more modification and it won't render again :S.

I tested it in some sample application to exclude my coding errors (http://insanitydesign.com/wp/projects/nehe-android-ports/ - the blending example), just changed blending function to my needs.

It behaves just like my app.

Did anyone find a workaround of some kind?

Twiggy