Trick - Barrier broken! Up to 2700 % Faster Plot()
Mhhhh... Very cool news for you... The speed barrier with PureBasic Plot() has been broken! Some of you (like me) are not really happy with the speed when using Plot()! Btw for normal things the speed of Plot() itself is ok... The only problem why it slows so very down is the use of FrontColour()
Yes, this is not a bad joke! You dont need any inline asm, new libs or dll calls! You need only the normal included PureBasic commands and with a small nice trick we will speed up our Plot() command up to 2700 percent (two-thousand-seven-hundret)!
I wrote a small "Animation-Precalculation-System" for my 32k game! The complete animation sequence (small one) needed on my system 1.7 - 1.75 seconds... Then i have had an idea how to speed it up... Now the same stuff needed 1.48-1.49 seconds...
Some time ago i have had an idea how it could be possible to speed up the Plot() mutch more... So i tried to code my small experience... and YES - it works very fine... The same stuff was now very fast and the stuff was finished in only 0.22 - 0.24 seconds on my system... YEAH!!!
I tried my trick on a 640x480 screen and the complete screen was filled in ONLY 1.7 seconds... The Original Plot() command need for this resolution 46.41 seconds!!!
How does it work?
Its really easy to understand... If you want plot any graphic to the screen,
you may know in most sence how does this palette looks like... If you want to plot an image with a size of 200x200 in 256 clours, you have to do folling steps:
You need your palette data and do something like following [basic-code]:
Code: Select all
;-------- Generating PaletteBrush --------
;
StartDrawing(ScreenOutput())
For x=0 To 255
FrontColour (x,x,x) ; x = here you can store your real palette data too
Plot (x,0)
Next
StopDrawing()
;
GrabSprite (100,0,0,400,1) ; Now we have our PaletteBrush, hehe
;
;-------- Drawing our Image -------
;
For x = 0 to 63
For y = 0 to 63
newcol = Random(0,255) ; Just randomize some colours!
ClipSprite(100,newcol,0,1,1) ; Use our PaletteBrush and set to 1x1 pixel
DisplaySprite(100,x,y) ;
Next
Next
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Edited by - MrVainSCL on 17 March 2002 18:44:35