glfx.js icon indicating copy to clipboard operation
glfx.js copied to clipboard

Error: WebGL warning: readPixels: Incompatible format or type.

Open webciter opened this issue 7 years ago • 1 comments

Error: WebGL warning: readPixels: Incompatible format or type. When using the getPixelArray(). I need the function getImageData() from the context how can i get this.

webciter avatar Apr 09 '18 15:04 webciter

I was having the same issue and got around it using this

// this.canvas is the canvas created with glfx

getPixels() {
		let texture = this.canvas._.texture,
			gl = texture.gl,
			size = texture.width * texture.height * 4,
			pixels = new Uint8Array(size);
			
		texture.use();
		gl.defaultShader.drawRect();
		gl.readPixels(0, 0, texture.width, texture.height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
		
		return pixels;
	}

i used chunks of the source code from Canvas.toImage

Zaphiruz avatar Jun 06 '18 19:06 Zaphiruz