# SDL C++ Flood Fill Performance

I'm using SDL and I need to quickly fill a lot of polygons (fake 3D walls, made linking calculated points with the SDL_RenderDrawLine() function, that I need to colour).

I tried to implement the filledPolygon() function from SDL_gfx.h but since I didn't see any improvement, I gave up.

I also searched for a multithreading implementation but after some tries I understood that it wasn't the best way to deal with my problem.

Finally, I tried to make a for loop where I call SDL_RenderDrawLines() every time.

Yes, I know that's the worst thing that I could do (indeed I ascertained that whats slowing down my program is that continuous function calling in the loop) but I don't really know what to do.

What's the best way to accomplish flood filling in SDL2?

I'm using SDL_RENDERER_ACCELERATED flag and I need to render even 150/200 polygons without any problem. With the actual code a single polygon placement is capable of slowing by 4 times my program so I can barely place a small polygon without making the program useless.