I am trying to display an image in SFML.
Here's what I have:
sf::Sprite loadSprite(std::string filename)
{
sf::Texture texture;
texture.loadFromFile(filename);
return sf::Sprite(texture);
} // error: the texture is destroyed here
...
sf::Sprite sprite = loadSprite("ufo.png");
window.draw(sprite);
Unfortunately, the sprite doesn't display. I just get a white screen. Any ideas what is wrong?