This worked for me:
In the surfaceView Constructor
setEGLConfigChooser(8, 8, 8, 8, 0, 0);
getHolder().setFormat(PixelFormat.RGBA_8888);
In the View.Renderer onSurfaceCreated
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
Lastly the textures will need to be 32bit and they will need to have
widths and lengths of 32, 64, 128, 256, 512
you can have 128x512 if you want.
Hope that helps, took me ages to piece it together :)
On May 28, 3:00 am, Nate <[email protected]> wrote:
> I am rendering this PNG with no transparency just
> fine:http://n4te.com/temp/test.png
> However if I try to render this PNG (with transparency) with the exact
> same code, I just get a white box:http://n4te.com/temp/ball.png
>
> I am loading the PNG into a texture like this:
> Bitmap bitmap = BitmapFactory.decodeStream(input);
> int[] temp = new int[1];
> gl.glGenTextures(1, temp, 0);
> textureID = temp[0];
> gl.glBindTexture(GL10.GL_TEXTURE_2D, textureID);
> 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_NEAREST); // GL_LINEAR for quality.
> 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);
> GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
> bitmap.recycle();
>
> I am using this blending:
> gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
>
> How is it possible to render a PNG with transparency in OpenGL ES?
>
> Thanks!
> -Nate
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---