Is it cheap to change the texture for tgui::Picture?

Started by GetterSetter, 28 April 2024, 08:53:23


Hello, I have a set of textures and need to display them one by one, like in a photo viewer. I've made some research and found that when I use setTexture(), it actually copies the texture into the internal one (is that correct?). So, is it better to store a set of textures and call setTexture every time, or a collection of Pictures and change them?


Copying tgui::Texture objects or setting them in a picture are light operations.
What is a very heavy operation (other than loading the image from disk) is to create a tgui::Texture object from an sf::Texture one. So calling setTexture with an sf::Texture each time would be a bad idea.

A collection of pictures would be fine, but having a list of tgui::Texture objects and then calling setTexture on a single picture would have slightly less overhead.