Copy rendered content to a PImage
in
Programming Questions
•
3 years ago
Hello guys,
I have been working with processing for a few, primarly to make some animations and interactivity to my kids (processing/oF). Now I want to do some water ripples (my logical next move) but I have had slow framerate problems.
the process I am following is:
1.render everything
2.loadpixels
3.move pixels to pixels of a PImage.pixels (canvas.pixel)
4.alter the canvas.pixels with the ripple effect (that I have ported from C++ where I have made a few of them that run fast ecough).
5.render the canvas.
now, if I don't do the ripple, the framerate of my animations is steady at 60 (setFramerate(60);) but when I add the ripple effect, the framerate goes to 3 or 4.
Actually, by just doing steps 2 and 3 (skipping ripple function) my framerate drops to 3 or 4.
knowing my problem, I'd like to ask:
1.¿Is there a way of changing the default canvas for rendering to a PImage? eg. set processing canvas to x, so whenever I render instead of rendering to screen I'd render to a buffer.
2.-if not, ¿How can I render to a PImage? canvas.Image()?
3.-Is there a faster way of getting the rendering buffer pixels than loadpixels and copying to a PImage.pixels?
and another question not related to my foolish problem. Is there a way of using the GPU for doing some math with processing, like OpenCL? I am more C++ than Java, but Processing is making Java more interesting... :)
thanks in advanced for the replies.
I have been working with processing for a few, primarly to make some animations and interactivity to my kids (processing/oF). Now I want to do some water ripples (my logical next move) but I have had slow framerate problems.
the process I am following is:
1.render everything
2.loadpixels
3.move pixels to pixels of a PImage.pixels (canvas.pixel)
4.alter the canvas.pixels with the ripple effect (that I have ported from C++ where I have made a few of them that run fast ecough).
5.render the canvas.
now, if I don't do the ripple, the framerate of my animations is steady at 60 (setFramerate(60);) but when I add the ripple effect, the framerate goes to 3 or 4.
Actually, by just doing steps 2 and 3 (skipping ripple function) my framerate drops to 3 or 4.
knowing my problem, I'd like to ask:
1.¿Is there a way of changing the default canvas for rendering to a PImage? eg. set processing canvas to x, so whenever I render instead of rendering to screen I'd render to a buffer.
2.-if not, ¿How can I render to a PImage? canvas.Image()?
3.-Is there a faster way of getting the rendering buffer pixels than loadpixels and copying to a PImage.pixels?
and another question not related to my foolish problem. Is there a way of using the GPU for doing some math with processing, like OpenCL? I am more C++ than Java, but Processing is making Java more interesting... :)
thanks in advanced for the replies.
2