Loading tgui::Picture
« on: 25 May 2013, 15:41:45 »
Is there any plans for other methods of loading tgui::Picture? It would be nice if tgui::Picture could be loaded from sf::Image or sf::Texture.
Right now I have to do a small workaround like this:

sf::Image test;
tgui::Picture::Ptr test2(some group);

test.saveToFile("temp.png");
test2->load("temp.png");

@Edit
To ensure the getLoadedFilename() method compatibility it could return empty string if tgui::Picture is loaded from sf::Image/sf::Texture.
« Last Edit: 25 May 2013, 15:43:54 by china92 »

*

texus

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Loading tgui::Picture
« Reply #1 on: 25 May 2013, 15:56:55 »
There aren't really any plans for that yet.
I would have to keep track whether or not the image was loaded from a file or not. It's not such a big change but I'm looking for a cleaner alternative.

But there is another workaround: create a panel with the size of the texture and use setBackgroundTexture on it.

In the future there will be another possibility because I will add an sfml canvas so that you can draw an sfml sprite in between tgui objects. (See blog post about combining sfml and tgui rendering)

Re: Loading tgui::Picture
« Reply #2 on: 25 May 2013, 16:52:10 »
Okay, but the Panel holds only the pointer to the texture, right? So then I have to make sure the texture exists?

Nice, so I'm looking forward to it. :)

*

texus

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Loading tgui::Picture
« Reply #3 on: 25 May 2013, 17:03:24 »
Okay, but the Panel holds only the pointer to the texture, right? So then I have to make sure the texture exists?
Yep