SFML community forums

Help => Graphics => Topic started by: Bertrahm on December 02, 2019, 06:54:13 pm

Title: Assertion Failed when trying to load Texture
Post by: Bertrahm on December 02, 2019, 06:54:13 pm
Hey,
im farely new to SFML and im having trouble when loadiong Textures. Im getting an Assertion Failed.
here's the message;
(click to show/hide)

Heres the class where I call the load texture:
(click to show/hide)
(LoadSprite calls LoadTexture, which really loads the texture)
And heres the class for my Window Creation and where I call the LoadSprite Function:
(click to show/hide)

It fails at window creation, but as soon as I remove the LoadSprite call it doesnt fail anymore and the other way arround
Title: Re: Assertion Failed when trying to load Texture
Post by: Laurent on December 02, 2019, 08:23:07 pm
Do you declare your Engine instance at global scope? Within main()? Somewhere else?
Title: Re: Assertion Failed when trying to load Texture
Post by: eXpl0it3r on December 02, 2019, 08:31:01 pm
As mentioned on Discord, your LoadTexture function isn't returning anything.

// Method for loading Textures
sf::Texture SpriteLoader::LoadTexture(string name) {
    sf::Texture texture;

    if(!texture.loadFromFile(GetResourceLocation()+"/"+name)) {
        cout << "[ERROR]HE: SpriteLoader: Texture failed to load! (" << name << ")" << endl;
    }
}

Not even sure how this code is compiling for you.