Is there something like Canvas:overwriteOldImageData() ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Is there something like Canvas:overwriteOldImageData() ?

Post by raidho36 »

You know you can do it fairly easily just by doing some math, right? Take a look at "shapes" section of this touchscreen library https://github.com/raidho36/love-multitouch it does exactly what you're doing, but without touching the GPU. And it's pretty fast, on account of being designed specifically for mobile, and can even return back the mouse/touch position in local coordinates, even if the element is transformed arbitrarily.
no_login_found
Prole
Posts: 18
Joined: Sun Dec 31, 2017 4:04 pm

Re: Is there something like Canvas:overwriteOldImageData() ?

Post by no_login_found »

raidho36 wrote: Thu Mar 01, 2018 5:23 pm Take a look at "shapes" section of this touchscreen library https://github.com/raidho36/love-multitouch it does exactly what you're doing, but without touching the GPU.
Ok, thanks for the link. However at the moment I want to go neither geometry path nor third-party lib path.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Is there something like Canvas:overwriteOldImageData() ?

Post by raidho36 »

As per MIT license, you can take any and all parts of the code and do with them as you see fit.

Anyway as I said originally, you don't need to read any of the pixels from GPU back to RAM, that's just unnecessary waste of performance. There's no such scenario where this approach outperforms basic geometry hit testing, simply due to GPU calls overhead.

As a final note, there's a saying "faster computational hardware is offset by programmers that write slower software". It exists for this very reason. Don't be that programmer.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests