Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 1.11 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Android OpenGL ES texture TextImage2D error
  2. public static void loadGLTexture(GL10 gl, Context context){
  3.  
  4.      BitmapFactory.Options options = new BitmapFactory.Options();
  5.      options.inDensity = 240;// needed so that the image will be 512x512
  6.  
  7.     Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.glasstexture, options);
  8.     int width = bitmap.getWidth();
  9.     int height = bitmap.getHeight();
  10.  
  11.     Log.i("GridLoginSquare.loadGLTexture 96", "Bitmap:{w:" + width + " h:" + height + "}");
  12.  
  13.     gl.glGenTextures(1, textures, 0);
  14.     gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
  15.  
  16.     // create nearest filtered texture
  17.     gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
  18.     gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
  19.  
  20.     // Use Android GLUtils to specify a two-dimensional texture image from our bitmap
  21.     GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);  //error is on this line
  22.  
  23.     Log.e("GridLoginSquare.loadGLTexture 102", " ERR "+gl.glGetError());
  24.     // Clean up
  25.  
  26.     bitmap.recycle();          
  27. }