Hi.
I want to get all pixel data of canvas.
But webgl readpixels is always returning 0,0,0,0
code :
var canvas = this.app.graphicsDevice;
var gl = this.app.graphicsDevice.gl;
var pixels = new Uint8Array(window.innerWidth * window.innerHeight * 4);
gl.readPixels(0, 0, window.innerWidth, window.innerHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
console.log(pixels) // return all [0,0,0,0]...
//using getElement is also situation the same as before
var canvas = document.getElementById('application-canvas');
var gl = canva.getContext("experimental-webgl", {preserveDrawingBuffer: true});
var pixels = new Uint8Array(window.innerWidth * window.innerHeight * 4);
gl.readPixels(0, 0, window.innerWidth, window.innerHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
console.log(pixels) // return all [0,0,0,0]...
Is it wrong ?
Please tell me how to get pixel data.