3

I'm developing a game for Android with libGDX framework. I have three images - background, foreground and a mask. Here is the rendering code to make part of background image visible on foreground image using mask:

Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.enableBlending();
batch.begin();
batch.setBlendFunction(<params1>);
batch.draw(bgTex, bgTexX, bgTexY, bgTexW, bgTexH);
batch.setBlendFunction(<params2>);
batch.draw(mask, maskX, maskY, maskW, maskH);
batch.setBlendFunction(<params3>);
batch.draw(fgTex, fgTexX, fgTexY, fgTexW, fgTexH);
batch.end();

It works well on desktop (ubuntu 12.04) but it doesn't work on any android phone/tablet I tried it on (they all support Opengl Es 2.0). What can be wrong with blending on Android devices?

1 Answers1

0

In your android project file do you use

AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = true;        
initialize(new MyGdxGame(), cfg);

As if the App configuration isn't set to allow the use of GL20 it will ignore all calls to the GL20 object. The default (if it isn't explicitly set) is false.

LiamJPeters
  • 486
  • 3
  • 9
  • 1
    Yes, I set this option in application configuration. After some time of experimenting I finally managed to modify an algorithm - now I use a black&white mask instead of alpha mask and another set of blending params. It works correctly on desktop and android. So it seems something was wrong with the initial params combination. – user1793975 Nov 06 '12 at 09:12