PNG Textures not loading on HTC desire

All your problems with Audio, Video and Images.

PNG Textures not loading on HTC desire

Postby MATT1980 » Wed May 19, 2010 5:51 pm

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:

Code: Select all
      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.
         }
      }


Any help/suggestions on this would be great.
MATT1980
Freshman
Freshman
 
Posts: 6
Joined: Wed May 19, 2010 5:37 pm

Top

Re: PNG Textures not loading on HTC desire

Postby Christoph » Wed May 19, 2010 8:38 pm

try 32 bit png's !
User avatar
Christoph
Developer
Developer
 
Posts: 28
Joined: Thu Jul 02, 2009 3:34 am
Location: Bonn, Germany

Re: PNG Textures not loading on HTC desire

Postby MATT1980 » Wed May 19, 2010 9:56 pm

Thanks Christoph

I'm pretty sure that they are 32 bit but I'll double check
MATT1980
Freshman
Freshman
 
Posts: 6
Joined: Wed May 19, 2010 5:37 pm

Re: PNG Textures not loading on HTC desire

Postby MATT1980 » Thu May 20, 2010 12:15 pm

My pngs do have a bit depth of 32 bit, as I say it works fine on the emulator (1.5, 1.6, 2.1) and on an HTC Hero. It's only when I deploy to my HTC Desire that it doesn't work.

I'm thinking that it may be the GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0) call as I am not supplying the type or internal format values but letting the system work them out. Do I need to supply values for these parameters and if so what would they be?
MATT1980
Freshman
Freshman
 
Posts: 6
Joined: Wed May 19, 2010 5:37 pm

Re: PNG Textures not loading on HTC desire

Postby MATT1980 » Fri May 21, 2010 12:12 pm

OK so GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0) doesn't seem to be the problem but I did notice that the EGLConfig is different when debugging on the phone to when it's running on the emulator. I have tried calling setEGLConfigChooser on the GLSurfaceView with a few different values but they either make no difference or crash the phone!

Is there anyone that can help with this please?
MATT1980
Freshman
Freshman
 
Posts: 6
Joined: Wed May 19, 2010 5:37 pm

Re: PNG Textures not loading on HTC desire

Postby MATT1980 » Fri May 21, 2010 6:05 pm

24 bit pngs render fine btw just with no transparency (which I need) :-(
MATT1980
Freshman
Freshman
 
Posts: 6
Joined: Wed May 19, 2010 5:37 pm

Top

Re: PNG Textures not loading on HTC desire

Postby MATT1980 » Mon May 24, 2010 4:18 pm

OK I seem to have solved this by setting the texture mode to GL_MODULATE for 2D pngs and GL_REPLACE for mapping to 3D objects. Not sure why this is but at least it works now!
MATT1980
Freshman
Freshman
 
Posts: 6
Joined: Wed May 19, 2010 5:37 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests