From c5872ef5a1a1e2f6a123f4c8d19befbd9aa89ae0 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Tue, 10 Oct 2017 21:09:26 +0200 Subject: [PATCH] Fixed broken webGl faking. Fixes #136 --- lib/modifiedAPI.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index 931bf7a..91b368b 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -31,8 +31,8 @@ var imageData; var source; if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){ - imageData = new getWrapped(window).ImageData(0, 0); - source = new getWrapped(window).ImageData(0, 0); + imageData = new (getWrapped(window).ImageData)(0, 0); + source = new (getWrapped(window).ImageData)(0, 0); } else if (context instanceof window.CanvasRenderingContext2D){ imageData = window.CanvasRenderingContext2D.prototype.getImageData.call( @@ -43,9 +43,13 @@ source = imageData.data; } else { - imageData = new getWrapped(window).ImageData(context.canvas.width, context.canvas.height); + imageData = new (getWrapped(window).ImageData)(context.canvas.width, context.canvas.height); source = new Uint8Array(imageData.data.length); - window.WebGLRenderingContext.prototype.readPixels.call( + ( + context instanceof window.WebGLRenderingContext? + window.WebGLRenderingContext: + window.WebGL2RenderingContext + ).prototype.readPixels.call( context, 0, 0, context.canvas.width, context.canvas.height, context.RGBA, context.UNSIGNED_BYTE,