Image with a black background OPENGL ES Android

Hi, I am playing with OPENGL Es on ANdroid and I am trying to display an image in my application. When I display an image (image characteristics are 64x64 pixels), I get a black background on the image, but when I put this code:

 public void draw(GL10 gl) {
... 
.. 
 gl.glAlphaFunc( GL10.GL_GREATER, 0 ); 

The black background fades, but I get weird colors in my image.

Does anyone have an idea how to fix this?

0
source share
1 answer

You need to use blending. Something like this should work:

gl.glEnable(gl.GL_BLEND);
gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINE_SRC_ALPHA);

The fact that you can use it glAlphaFuncand get closer to your result suggests that this is normal in itself.

+1
source

All Articles