Canvas draw speed

BlitzMax Forums/MaxGUI Module/Canvas draw speed

blackwater(Posted 2010) [#1]
Hi everyone, as I posted in several threads before, I've been coding a game editor and it's been going quite well but I just hit a snag. Basically, the more objects I have on screen (which isn't a lot) the more I notice a delay in drawing them.

I don't want to post a bunch of code for anyone to sift through but let me try and sum it up. I select an image, in this case a simple colored square and place it on the canvas, it's 64x64 size. When I place an object I call redraw canvas to redraw everything using the DrawImageRect function. When I have let's say 15 of these blocks on the screen, selecting one, moving one, even placing another one there is a decent delay.

When I redraw the canvas I am loading the image from disk using the LoadImage function for each image. Should I be using a bank instead and not loading them from disk every time there is a redraw?

Any other general suggestions and how to speed things up?


jhans0n(Posted 2010) [#2]
You definitely don't want or need to do a LoadImage each time. Load the image once, and draw it as many times as you need to.

Also, you may find that it's even faster if you put all of your 64x64 images into one big 1024x1024 image (or whatever), and use DrawSubImageRect to draw them.


blackwater(Posted 2010) [#3]
In case anyone reads this thread in the future - after re-coding some functions so that only an image is only loaded once and the canvas is re-drawn from that loaded image, the result is like night and day. Now I can move, select, add, etc without any lag at all!


ziggy(Posted 2011) [#4]
Yes, disk operations are usually the slower ones when coding. Keep this in mind