white rectangle when trying to display a sprite

Viewed 16

Hi i made this function that create a sprite from a filepath :

sf::Sprite create_sprite(std::string filename)
{
    sf::Texture texture;
    if (!texture.loadFromFile(filename))
        std::cout << "it's not working" << std::endl;
    sf::Sprite sprite;
    sprite.setTexture(texture, true);
    return (sprite);
}

But when i try to display it i have a white rectangle i've been searching on google but on the official sfml manual there's no solution. Thanks for your help !

0 Answers
Related