Extract pixel from correct location for a framebuffer

This commit is contained in:
Richard Davey 2019-07-14 16:00:35 +01:00
parent 15d7b9c6ef
commit dfba4ae817

View file

@ -41,7 +41,9 @@ var WebGLSnapshot = function (sourceCanvas, config)
{
var pixel = new Uint8Array(4);
gl.readPixels(x, bufferHeight - y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
var destY = (isFramebuffer) ? y : bufferHeight - y;
gl.readPixels(x, destY, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
callback.call(null, new Color(pixel[0], pixel[1], pixel[2], pixel[3] / 255));
}