Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGL extract giving empty image #3880

Closed
hackergrrl opened this issue Mar 25, 2017 · 5 comments
Closed

WebGL extract giving empty image #3880

hackergrrl opened this issue Mar 25, 2017 · 5 comments
Labels
🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim

Comments

@hackergrrl
Copy link
Contributor

I'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?

@ivanpopelyshev
Copy link
Collaborator

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.

renderer.extract.canvas(stage);

And if you are friday-night-drunk and forgot where is your stage

renderer.extract.canvas(renderer._lastObjectRendered);

@ivanpopelyshev ivanpopelyshev added Domain: Documentation 🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim labels Mar 25, 2017
@englercj
Copy link
Member

Hey @noffle is this still an issue?

@hackergrrl
Copy link
Contributor Author

@ivanpopelyshev That did it! Thank you so much. ❤️ And thanks @englercj for poking me on this.

@gebeto
Copy link

gebeto commented Oct 17, 2018

@ivanpopelyshev Спасибо тебе огромное!

@lock
Copy link

lock bot commented Oct 17, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Oct 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim
Projects
None yet
Development

No branches or pull requests

4 participants