WebGL extract giving empty image
See original GitHub issueI’m trying to use the WebGLExtract class to create screenshots, but am getting a black image instead (of the correct dimensions).
var sourceCanvas = renderer.extract.canvas();
var sourceContext = sourceCanvas.getContext('2d');
var extractCanvas = document.createElement('canvas');
var extractContext = extractCanvas.getContext('2d');
var imageData = sourceContext.getImageData(x, y, width, height);
extractCanvas.width = width;
extractCanvas.height = height;
extractContext.putImageData(imageData, 0, 0);
return extractCanvas.toDataURL();
I’ve also tried just accessing sourceCanvas.toDataURL()
directly, but with the same results. Any chance I’ve forgotten something obvious?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
WebGL extract giving empty image · Issue #3880 - GitHub
I'm trying to use the WebGLExtract class to create screenshots, but am getting a black image instead (of the correct dimensions). var ...
Read more >HTML Save WebGL Canvas as Image - Stack Overflow
The reason the webgl canvas is blank has been answered at least 10 times here on stackoverflow. Saving canvas to image via canvas....
Read more >CanvasRenderingContext2D.getImageData() - Web APIs | MDN
This example draws an image, and then uses getImageData() to grab a portion of the canvas. We use getImageData() to extract a slice...
Read more >WebGL - Quick Guide - Tutorialspoint
To create an empty buffer object, WebGL provides a method called createBuffer(). This method returns a newly created buffer object, if the creation...
Read more >Fabric.js filtering overview — Fabric.js Javascript Canvas Library
Webgl context is more complicated to handle than canvas2d context. To be filtered images needs to be put in a texture. Texture size...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It can happen in some cases, but if you pass your stage there, and it gets imageData just after rendering it - I’m sure it’ll work.
And if you are friday-night-drunk and forgot where is your stage
@ivanpopelyshev That did it! Thank you so much. ❤️ And thanks @englercj for poking me on this.