get() and copy() don't work in WEBGL mode?

in Processing I would use something like

PImage img = get();

to get a snapshot of the current look of the screen but 'var img = get()' does not seem to work with p5js & WEBGL?

Nor does: var img; img = createGraphics(100,100); img = get();

so if this can be done: how?



  • edited July 2016

    Given WebGL is still under heavy development over p5.js' side; plus the fact they're implementing 3D differently compared to Processing's Java, I'd say many bugs gonna keep showing up there. :|

    There's also the fact p5.js' p5.Renderer isn't a subclass of p5.Image! @-)

    Therefore there's no guarantee that some p5.Renderer instance got all methods and behaves as a p5.Image. :-SS

    To make things even worse, createGraphics() doesn't return a pure p5.Renderer but a wrapper for it called p5.Graphics.

    Here's the crazy thing: we can invoke all p5.js' API over a p5.Graphics instance. For example sqrt() or year(). 8-}

    IMO, all these issues make images unnecessarily prone to silly, but preventable, bugs to spawn. And demand other buggy "band-aids" in order to equalize p5.Image & p5.Renderer methods. #:-S

  • As an attempt workaround, you may invoke loadPixels() before get().

    Also take a look at some reported issues there:✓&q=is:issue is:closed loadPixels()%20

    Or do your own issue report:

  • loadPixels() seems not to work when used in a WEBGL canvas?

    19124: Uncaught TypeError: undefined is not a function

  • edited July 2016

    yes, I've asked it there and just got an answer ;)

Sign In or Register to comment.