Reputation: 717
I'm running into trouble with LibGdx developing an 3D Android app. I metioned it briefly in my answer to my own question, but I have been unable to figure out why I cannot get transparency from .png images.
The textures are transparent, I've checked in my OpenGL3+ framework on windows and they show transparent in the correct parts.
My (simple placeholder) fragment shader code ends with:
vec4 finalColor = ambient + diffuse;
finalColor.a = colorMap.a;
gl_FragColor = finalColor;
I've tried finalColor.a = 0.1;
which doesn't work.
I've added this to my code but to no avail:
Gdx.gl20.glEnable(GL20.GL_DEPTH_TEST);
Gdx.gl20.glBlendFunc(GL20.GL_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Gdx.gl20.glEnable(GL20.GL_BLEND);
I've even checked and changed:
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.r = cfg.g = cfg.b = cfg.a = 8;
Which I though was the number of bits per channel.
Any help at all on this would be appreciated, I just hope I've not overlooked anything. It's not a gigantic issue, and I could more or less complete my project without transparency, but would really like to know why I cant get it to work.
Upvotes: 3
Views: 3796
Reputation: 35933
GL_ALPHA
is not a legal option for glBlendFunc
. You either want GL_SRC_ALPHA
(most likely), or GL_DST_ALPHA
.
glGetError
would have been helpful to you here, you should start using it!
http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html
Upvotes: 5