Alpha component in color buffer affects RGB components? 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
It looks like you're drawing with pre-multiplied alpha. This means that the red, green, and blue channels have been multiplied by the alpha channel. So your shader should look more like this:

precision mediump float;
uniform sampler2D uSampler;
varying vec2 vTextureCoord;
void main() {
    vec4 originalColor = texture2D(uSampler, vTextureCoord);
    vec4 tempColor = originalColor + vec4(0, 0, 0, -0.5);
    tempColor.rgb *=  tempColor.a;
    gl_FragColor = tempColor;
}


I believe you also need to set glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) to get the correct blending (and of course, glEnable(GL_BLEND)).