Draw to Texture Help - Faster Way?

BlitzMax Forums/MiniB3D Module/Draw to Texture Help - Faster Way?

FBEpyon(Posted 2016) [#1]
Hello All,

I'm trying to find a faster way to pull a tile image from an atlas, and then put it into a BufferToText..



Full code : http://www.blitzmax.com/logs/userlog.php?user=2168&log=1907

Any help would be great..

Thanks,


grable(Posted 2016) [#2]
First, dont call LoadImage() in SetTileAt() as that will reload from disk every time.
And use LoadPixmap() instead if your just gonna Lock it anyway, no need to pay for the texture upload if your not gonna use it.

I also see that you Lock the image, yet never use the pixmap it returns, which means ReadPixel() might be locking and unlocking on each call, probably.

Then try using TPixmap.Window() and TPixmap.Paste() instead of ReadPixel/WritePixel.

If that is still too slow, find the X,Y coords of source and destination in INDICES into TPixmap.Pixels. And then copy whole lines over at a time with something like MemCopy.
Though for 16x16 it might be faster to do it manually, you should probably bench it ;)

EDIT: If you go for copying pixels manually, there is no need for a buffer. Nor do you need it in the code you posted above.


FBEpyon(Posted 2016) [#3]
Thanks..

I was working on this at work.. so I'm limited to what can be tested, I did notice the errors after I posted this.. going to work on it more..

Thanks,