Page 1 of 1

Grab part of screen, draw, replace

Posted: Wed Feb 21, 2018 5:18 pm
by mr_happy
I'm sure I've done this before, but I haven't done any coding of late and can't recall how to go about it:

I need to copy part of the back-buffer (or whatever its called these days), draw some stuff on it then copy it back to the screen before it's displayed. The part being copied, drawn to then copied back, is of constant size so doesn't need to be created on the fly. What's the quickest way to do this?

In other libraries I've used it would be a case of creating a new image, copying a quad to it from the back-buffer, setting it as the draw target, drawing then copying it back. I'm getting lost in canvases and imagedata on the wiki! No code example required, just a nudge in the right direction would be great.

TIA

Re: Grab part of screen, draw, replace

Posted: Wed Feb 21, 2018 6:55 pm
by raidho36
You can draw to an intermediate render target, then perform manipulations with it, and finally put it on the screen.

Re: Grab part of screen, draw, replace

Posted: Wed Feb 21, 2018 7:11 pm
by mr_happy
raidho36 wrote: Wed Feb 21, 2018 6:55 pm You can draw to an intermediate render target, then perform manipulations with it, and finally put it on the screen.
Hehe yeah that's pretty much what I want to do (well, do a normal draw, copy part of that to the intermediate target etc) just can't see how atm :D

Re: Grab part of screen, draw, replace

Posted: Wed Feb 21, 2018 7:17 pm
by pgimeno
To make it general, you need two canvases. One would be the back buffer, and the other the copied quad.

You would draw to the backbuffer canvas rather than to the screen, and in love.draw, you would draw the backbuffer to the screen.

To copy a quad, you need to draw that canvas on the second canvas.

There are probably better ways for specific usages.

Re: Grab part of screen, draw, replace

Posted: Wed Feb 21, 2018 8:13 pm
by mr_happy
pgimeno wrote: Wed Feb 21, 2018 7:17 pm To copy a quad, you need to draw that canvas on the second canvas.
There are probably better ways for specific usages.
Thanks for the help, got it now. Must be my age :D