Hello! I can't load a background for a window. That's my code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
while (window.isOpen())
{
// Process events
sf::Event event;
sf::Image image;
image.loadFromFile("texture.png");
sf::Texture texture;
texture.update(image);
sf::Sprite sprite;
sprite.setTexture(texture);
window.draw(sprite);
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
What did I do wrong? Thank you