What I don't know is what format it is in after Android has loaded it as a Bitmap and passed it to GL. Also, I don't know if there can be memory savings by somehow indicating to OpenGL that the image only needs 8bits per pixel instead of 24. or 32, or whatever RGBA_8888 uses.
I tried adding a format field like GL_LUMINANCE to GLUtils.texImage2D(), but ended up with a corrupted image. I assume that is because the Bitmap was already in a different format, but I'm not sure how to change it.
Here's my texture loading code:
Using java Syntax Highlighting
- gl.glGenTextures(1, mTextureNameWorkspace, 0);
- int textureName=mTextureNameWorkspace[0];
- t.name=textureName;
- InputStream is = context.getResources().openRawResource(t.resource);
- Bitmap bitmap = null;
- Bitmap temp = null;
- try {
- temp = BitmapFactory.decodeStream(is);
- bitmap = Bitmap.createBitmap(temp, 0, 0, temp.getWidth(), temp.getHeight(), flipY, false);
- temp.recycle();
- } finally {
- try {
- is.close();
- is = null;
- } catch (IOException e) {
- }
- }
- gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);
- gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
- gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
- GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


