which is fastest?...

BlitzPlus Forums/BlitzPlus Programming/which is fastest?...

WoeIsMe(Posted 2004) [#1]
I have two ways of drawing a series of repeated images in a particular rectangle of screen

One method is to use a For...Next loop to draw the image at selected intervals from its x_postion to its x_postion+length. And vertically from it's y_position to its y_postition+length, except for the images at the edges where I use DrawImageRect to draw a specified fraction of the image. I will tell the programme only to draw the tiles when they are on the screen.

My other option is to use a Viewport command, and use TileImage to place all the images rpeated inside the Viewport. With some coding, I make sure that the viewport never goes off the screen.

I hope that's been good enough description for you. I'll give examples if I need to, but at the moment I haven't written out the code for both for the same object.

Essentially the question is whether it's faster to use a For...Next loop with repeated DrawImage commands, or to use Viewport and TileImage.

Thanks in advance!


Bremer(Posted 2004) [#2]
I would think that tileimage would be faster as you don't have to have anything checking for drawing partial rects. And if its the first thing you are drawing and don't need it to mask or anything then Tileblock is what you want to use, as it doesn't take into consideration the mask of the image and just overdraws everything already there.


WoeIsMe(Posted 2004) [#3]
thanks! :D


Hotcakes(Posted 2004) [#4]
I don't know. Viewport/TileImage has some clipping it has to take into account. Depending on the situation, ie you knew there was no clipping and you knew exactly what offset you wanted the pictures tiled at, For/Next *could* be faster? I suppose testing it yourself is the only way to know for sure.


Rottbott(Posted 2004) [#5]
Perhaps a combination of the two would be faster. Use a simple pair of For/Next loops to draw the images, but don't bother with the DrawImageRect to draw partial images - use the Viewport instead.