java - Alpha blending not working on Android libgdx but works on Desktop -



java - Alpha blending not working on Android libgdx but works on Desktop -

i'm having weird problem alpha blending in libgdx. i'm doing drawing background picture, drawing mask (done using shaperenderer) , drawing foreground. mask works fine on desktop not on android devices (galaxy s2, lenovo ideatab a2109). have no thought what's going on. help me out? or @ to the lowest degree give me hint on what's going on. thanks

result on desktop:

result on phone:

my render function:

gdx.gl.glclearcolor(0f, 0f, 0f, 0); gdx.gl.glclear(gl20.gl_color_buffer_bit); batch.setprojectionmatrix(camera.combined); camera.zoom = 1f; camera.update(); batch.begin(); drawbackground(batch); batch.end(); framebuffer.begin(); line.drawmask(false); framebuffer.end(); fboregion.settexture(framebuffer.getcolorbuffertexture()); batch.begin(); drawmask(batch); drawforeground(batch) batch.end();

draw functions:

private void drawbackground(spritebatch batch){ batch.setblendfunction(gl20.gl_src_alpha, gl20.gl_one_minus_src_alpha); page1.draw(batch); page2.draw(batch); batch.flush(); } private void drawmask(spritebatch batch){ gdx.gl.glcolormask(false, false, false, true); batch.setblendfunction(gl20.gl_one, gl20.gl_zero); batch.draw(fboregion, 0, 0); batch.flush(); } private void drawforeground(spritebatch batch){ gdx.gl.glcolormask(true, true, true, true); batch.setblendfunction(gl20.gl_dst_alpha, gl20.gl_one_minus_dst_alpha); page3.draw(batch); batch.flush(); }

edit: how using shaders instead of alpha mask? e.g. replace white pixels shaperenderer foreground image pixels. idea?

opengl es 2.0 doesn't guarantee 8888 frame buffer's color buffer. work on devices. have utilize rgba4444, rgb565, or rgb5_a1.

i can @ to the lowest degree utilize 8888 on devices opengl es 3.0 , on desktop:

format format = (gdx.graphics.getgl30()==null && gdx.app.gettype()!=applicationtype.desktop) ? format.rgb565 : format.rgba8888;

java android libgdx opengl-es-2.0 blending

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -