u/BeneficialRice9328

▲ 2 r/sfml

class Renderer {

sf::Texture textures[12];

std::vector<sf::Sprite> sprites;

Renderer () {

const std::string files[12] = {

"white-pawn.png", "white-knight.png", "white-bishop.png", "white-rook.png", "white-queen.png", "white-king.png",

"black-pawn.png", "black-knight.png", "black-bishop.png", "black-rook.png", "black-queen.png", "black-king.png"

};

sprites.reserve(12);

for (int i = 0; i < 12; i++) {

std::string file = "images/" + files\[i\];

if (!textures\[i\].loadFromFile(file)) {

	std::cout &lt;&lt; "Couldn't load file " &lt;&lt; files\[i\] &lt;&lt; std::endl;

}

sprites.emplace\_back(textures\[i\]);

}

}

}

Here is roughly what the class looks like. When I try to load the images I get this:

Failed to load image

Provided path:

Absolute path:

Reason: No such file or directory

Couldn't load file white-pawn.png

The path definetly exists I checked with filesystem. I gave the absolut path and it still didn't load. Please help me.

reddit.com
u/BeneficialRice9328 — 29 days ago