SFML community forums

Help => General => Topic started by: kepler0 on September 09, 2017, 06:02:53 pm

Title: How should I avoid calling draw every frame?
Post by: kepler0 on September 09, 2017, 06:02:53 pm
I've recently found out drawing 6000+ Sprites/Shapes is very heavy on performance, and I require advice on how I should begin handling this.

I intend to have an upwards of 1 million Sprites/Shapes in the future, and this can only worsen as I am actually drawing these 6000 sprites/shapes twice (one for the minimap, one for the main view). Obviously ~12000 draw calls every frame is going to slow down any computer, but I'm interested in how VertexArray handled this issue.

The first, most obvious route to take is chunking, but with the way I have things set up right now, implementing chunking would go against the framework of my program. Are there any other ways I can cut down the unnecessary draw calls per frame, or draw them in a more optimized way?

Thanks.
Title: Re: How should I avoid calling draw every frame?
Post by: eXpl0it3r on September 09, 2017, 06:35:09 pm
A vertex array uses only one draw call per texture, which cuts down on performance due to draw calls being expensive.

If only part is visible you should only upload these vertices and not everything. If your framework isn't set up for, then you may want to change that.

Other potential optimizations, especially maybe for the minimap is, to render the static data to a render texture and use that, instead of redrawing everything.
Title: Re: How should I avoid calling draw every frame?
Post by: kepler0 on September 09, 2017, 07:16:04 pm
Thanks for the advice. I've already got it back up to a smooth stable framerate, but I'm still working on it to maintain an acceptable amount of detail, especially since the minimap can be zoomed in and out.