I tried everything..
Source:

Texture class:
public class XAndroidTexture
{
       private int[] textures = new int[1];
       public int width, height;
       Bitmap bmp;
       public XAndroidTexture(GL10 gl, Bitmap bitmap)
       {
               gl.glEnable(GL10.GL_TEXTURE_2D);
               this.bmp = bitmap;
               width = bmp.getWidth();
               height = bmp.getHeight();
               gl.glGenTextures(1, textures, 0);
               // ...and bind it to our array
               gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
               // create nearest filtered texture
               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);
       gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
GL10.GL_CLAMP_TO_EDGE);
       gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
GL10.GL_CLAMP_TO_EDGE);
                gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
GL10.GL_MODULATE);
               // Use Android GLUtils to specify a two-dimensional texture 
image
from our bitmap
               GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
                //GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bmp);
               // Clean up
               bitmap.recycle();
       }
       public void bind(GL10 gl)
       {
               gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
       }
   public static XAndroidTexture createTextureFromBitmap(GL10 gl,
Bitmap bmp)
   {
       return new XAndroidTexture(gl, bmp);
   }
}


Texture loading function:


XAndroidTexture Textureload(String path)
       {
               InputStream is;
       Bitmap bmp = null;
               try
               {
                               is = this.getAssets().open(path);
               BitmapFactory.Options opts = new
BitmapFactory.Options();
               opts.inDither = true;
               Bitmap tBmp = BitmapFactory.decodeStream(is, null,
opts);
               bmp = Bitmap.createBitmap(tBmp.getWidth(),
tBmp.getHeight(), Bitmap.Config.ARGB_8888);
               Canvas canvas = new Canvas(bmp);
               canvas.drawBitmap(tBmp, 0, 0, null);
               canvas.save();
               tBmp.recycle();
               tBmp = null;
               }
               catch (IOException e)
               {
                       e.printStackTrace();
               }
               if(bmp == null)
                       return null;
               else
                       return new XAndroidTexture(gl, bmp);
   }


It working on Emulator perfect, but not on device....
Can anyone post here texture class that work on device?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to