GLBasic forum

Codesnippets => 2D-snippets => Topic started by: Qedo on 2018-Aug-10

Title: Fill Fast Line algorithm
Post by: Qedo on 2018-Aug-10
After i have grabbing with both hands in the forum a small summer gift (I hope it will be appreciated).
You find the scanline floodfill algorithm using stack instead of recursion.
I converted the version I found in internet from C++ to GlBasic.
Compared to the standard version this is much faster about 10-15 times.
When you start the program for the first 10 seconds, the standard (more slow) version is executed and  after the scanline version.
The program uses my FASTMEM2SPRITE version (which you already sent a while ago and which I have now improved), but you can comment the command and activate the standard MEM2SPRITE to appreciate even more the change of speed.
Let me know
Title: Re: Fill Fast Line algorithm
Post by: bigsofty on 2018-Aug-10
Cool, thanks Qedo!  :good:
Title: Re: Fill Fast Line algorithm
Post by: dreamerman on 2018-Aug-13
Nice, good to have such code ready for use in future. Did you tried other filling algorithms, even just to compare speed? Don't know what impact have those DIMPUSH / DELETE commands.
Title: Re: Fill Fast Line algorithm
Post by: Qedo on 2018-Aug-17
dreamerman, I searched the internet for the best filling algorithm and implemented it in GLB. I do not think there are others, but I can be wrong.
At the beginning I was very doubtful about the efficiency of DIMPUSH / DELETE and the FOREACH / NEXT cycle but I have to say that I'm not a real bottleneck. To get rid of all doubts it would be interesting to implement it in c ++ but for the moment I am satisfied with this version.