If you try to readPixels with format ALPHA on a RGBA texture, readPixels fails with:
"glReadPixels: format and type incompatible with the current read framebuffer"
It seems to me, from the spec, that format ALPHA should discard RGB and read alpha, instead of complaining that this is not a pure alpha texture.
Sample code:
texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 100, 100, 0, gl.RGBA, gl.UNSIGNED_BYTE, img);
fb = gl.createFramebuffer();
gl.bindFrameBuffer(fb);
gl.framebufferTextuer2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
buffer = new Uint8Array(100*100);
gl.readPixels(0, 0, 100, 100, gl.ALPHA, gl.UNSIGNED_BYTE, buffer);
I can write a full example later, if needed.
It seems, from checking gles2_cmd_decoder, that we don't even allow this format as a read input. :/
Comment 1 by fs...@chromium.org
, Mar 19 2018