title: SFML not loading image from file
body: <p>So I am learning C++ through game development and I recently ran across an error when I was trying to load an image called image1.png.</p>
  
  <p>I tried using directories and that didn't work and then i moved the image to the same directory as the .cpp file and it still doesn't load the texture.</p>
  
  <pre><code>// defining libraries
  #include &lt;SFML/Graphics.hpp&gt;
  #include&lt;iostream&gt;
  
  //global variables, functions, and classes 
  
  int main () {
  
      //SETUPS 
      sf::RenderWindow window(sf::VideoMode(800, 600),"SFML Game");
      window.setFramerateLimit(60);
      window.setKeyRepeatEnabled(false);
  
      bool play = true;
  
      sf::Event event;
  
      bool aPressed = false;
      bool aReleased = false;
      bool leftClick = false;
      bool space = false;
      bool returnReleased = false;
      bool rightClick = false;
  
      int numberOfClicks = 0;
      int mouseX, mouseY;
      int rectX = 0;
      int rectY = 0;
  
      sf::Texture image1;
      if (image1.loadFromFile("image1.png") == -1) {
          return 1;
      }
  
      sf::RectangleShape rect;
      rect.setSize(sf::Vector2f(100, 50));
      rect.setPosition(0, 0);
      rect.setTexture(&amp;image1);
  
      sf::CircleShape circle;
      circle.setRadius(50);
      circle.setPosition(50,50);
      circle.setFillColor(sf::Color::Magenta);
  
  
  
      //Game Loop 
  
      while (play == true) {
  
          //EVENTS 
          while (window.pollEvent(event)) {
              if (event.type == sf::Event::KeyPressed &amp;&amp; event.key.code == sf::Keyboard::A) {
                  aPressed = true;
              }
  
              if (event.type == sf::Event::KeyReleased &amp;&amp; event.key.code == sf::Keyboard::A) {
                  aReleased = true;
              }
  
              if (event.type == sf::Event::KeyPressed &amp;&amp; event.key.code == sf::Keyboard::Space) {
                  space = true;
              }
  
              if (event.type == sf::Event::KeyReleased &amp;&amp; event.key.code == sf::Keyboard::Space) {
                  space = false;
              }
  
  
              if (event.type == sf::Event::Closed) {
                  play = false;
              }
              if (event.type == sf::Event::KeyReleased &amp;&amp; event.key.code == sf::Keyboard::Escape) {
                  play = false;
              }
              if (event.type == sf::Event::MouseButtonPressed &amp;&amp; event.mouseButton.button == sf::Mouse::Left) {
                  leftClick = true;
              }
  
              if (event.type == sf::Event::KeyReleased &amp;&amp; event.key.code == sf::Keyboard::Return) {
                  returnReleased = true;
              }
  
              if (event.type == sf::Event::MouseButtonPressed &amp;&amp; event.key.code == sf::Mouse::Right){
                  rightClick = true;
              }
          }
  
          //LOGIC 
          if (aPressed == true) {
              std::cout &lt;&lt; "Key has been pressed\n";
              aPressed = false;
          }
  
          if (aReleased == true) {
              std::cout &lt;&lt; "Key has been released\n";
              aReleased = false;
          }
  
          if (leftClick == true) {
              numberOfClicks++;
              std::cout &lt;&lt; "Number of clicks: " &lt;&lt; numberOfClicks &lt;&lt; "\n";
              leftClick = false;
          }
  
          if (event.type == sf::Event::MouseMoved) {
              mouseX = event.mouseMove.x;
              mouseY = event.mouseMove.y;
              //std::cout &lt;&lt; "X:" &lt;&lt; mouseX &lt;&lt; "\n";
              //std::cout &lt;&lt; "Y:" &lt;&lt; mouseY &lt;&lt; "\n";
          }
  
          if (returnReleased == true) {
              std::cout &lt;&lt; "Return Released \n";
              returnReleased = false;
          }
  
          if (rightClick == true) {
              numberOfClicks--;
              std::cout &lt;&lt; "Number of clicks: " &lt;&lt; numberOfClicks &lt;&lt; "\n";
              rightClick = false;
          }
  
          rectX += 2;
          rectY += 1;
          rect.setPosition(rectX, rectY);
          rect.setTexture(&amp;image1);
  
  
          //RENDERING
          window.clear();
  
          window.draw(rect);
          window.draw(circle);
  
          window.display();
      }
  
  
      //Clean Up 
      window.close();
      return 0;
  }
  </code></pre>