I'm looking for a way to make my surface semitransparent, and for now i ended up using this configuration:
eglChooseConfig(eglDisplay, new int[] {
EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_NONE
}
My default configuration was:
eglChooseConfig(eglDisplay, new int[] {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_DEPTH_SIZE 16,
EGL10.EGL_NONE
}
As you can see, i added EGL_ALPHA_SIZE attribute and removed EGL_DEPTH_SIZE, since my application is a simple 2D drawing on a surface and it doesn't need a depth buffer. It works, but for some reason results in somewhat unexpected results for this simple fragment shader:
precision mediump float;
uniform sampler2D uSampler;
varying vec2 vTextureCoord;
void main() {
vec4 originalColor = texture2D(uSampler, vTextureCoord);
gl_FragColor = originalColor + vec4(0, 0, 0, -0.5);
}
The alpha component seems to be affecting rest of the parts of the color and changes it at some extent. The first image below is the original one, second is what I have, and the last one is what I want to achieve.
Any advice is appreciated, thanks!
For the sake of clarity
OpenGL ES Version: 2.0