Visual Studio says it can’t open my file for “graphics/background”. The reason it gives is that it is unable to open. Here’s what I have done. Can someone please help me?
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Window.hpp>
#include <SFML/Config.hpp>
#include <SFML/GpuPreference.hpp>
using namespace std;
using namespace sf;
int main()
{
Vector2f resolution;
resolution.x = VideoMode::getDesktopMode().width;
resolution.y = VideoMode::getDesktopMode().height;
RenderWindow window(VideoMode(resolution.x, resolution.y),"Real Men's Word Jumble",
Style::Fullscreen);
View mainView(sf::FloatRect(0, 0, resolution.x, resolution.y));
Vector2f mouseWorldPosition;
Vector2i mouseScreenPosition;
IntRect arena;
Texture textureBackground;
textureBackground.loadFromFile("graphics/background.jpg");
Sprite spriteBackground;
spriteBackground.setTexture(textureBackground);
spriteBackground.setPosition(0, 0);
cout << "Hello world";
while (window.isOpen())
//Handle the players input
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
window.close();
}
//Update the scene
window.clear();
//Draw the scene
window.draw(spriteBackground);
window.display();
return 0;
}
I have tried everything I have read online so far. I am at a loss. When I try to run it, it tells me, “Failed to load “graphics/background” Reason, unable to open. I have the background file in my graphics folder inside of my SFML folder. It can open everything else just not this. Can anyone please tell me why? What am I doing wrong? What do I need to do? Please Help.