hello guys, i have another problem. here's my code:
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
using namespace std;
int main()
{
RenderWindow window(VideoMode::getFullscreenModes()[0], "Chess Fantasy", Style::Fullscreen);
Texture board, wr, wp;
if (!board.loadFromFile("board.png") ||
!wr.loadFromFile("wr.png") ||
!wp.loadFromFile("wp.png"));
{
cerr << "Failed to load textures." << endl;
return 1;
}
float centerX = window.getSize().x / 2.0f;
float centerY = window.getSize().y / 2.0f;
RectangleShape board1(Vector2f(800, 800));
board1.setTexture(&board);
RectangleShape wr1(Vector2f(100, 100));
wr1.setTexture(&wr);
board1.setPosition(centerX - board1.getLocalBounds().width / 2, centerY - 400);
wr1.setPosition(centerX - board1.getLocalBounds().width / 2, centerY + 300);
RectangleShape wp1(Vector2f(100, 100));
wp1.setTexture(&wp);
wp1.setPosition(centerX - board1.getLocalBounds().width / 2, centerY + 200);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(board1);
window.draw(wr1);
window.draw(wp1);
window.display();
}
}
in my project's folder and debug folder i have board.png, wr.png, wp.png. but without any reason, it says "Failed to load textures." Other people have a reason, but i don't. also, i tried to insert the path to the file, but then it said "Failed to load textures. Reason: Unable to open file."
so, how do i fix that?