SFML community forums
Help => Graphics => Topic started by: xqbt on June 27, 2016, 08:22:19 pm
-
So, I need to draw a lot of text on the screen - an array of sf::Text objects. This text is not going to change very often. So, I thought, why not draw all these sf::Text objects on sf::RenderTexture object and then, when the text updates, just redraw the texture? Will drawing the sf::RenderTexture through a sprite in the main window be more efficient than drawing the text in the same window?
What I think is maybe drawing text is more expensive than drawing it once on a texture and then just drawing the texture.
-
It depends. Since both options are pretty easy to implement, you should just try.
-
Laurent, thanks for advice. I ran some tests, for anyone interested, here are the results.
1)
- Rendering 500 heavily overlapping text objects directly gained ~170 fps
- Rendering through sf::RenderTexture (without redrawing) gained ~380 fps.
.
2)
- Rendering 50 non-overlapping text objects directly gained ~470 fps
- Rendering through sf::RenderTexture (without redrawing) gained ~340 fps.
.
Well, the slowness of the second case with texture can be explained by the size of this texture - 800 * 800.
Anyway, bottom line: predrawing non-overlapping text is faster with plain text objects.