Before you start barking at me about incorrect file paths, I'd like to remind you that I've been using SFML for a long time on both Windows and Linux. I have ported an app from Linux to Windows on Visual Studio and I have the assets directory under the VC++ Project file directory. When I launch my program it says that SFML is unable to load the image. I have used an older version of SFML under my Linux machine so I don't know what's exactly changed with regards to how SFML loads images. The image I have is a *.png file so I assume SFML supports it because they use a png example on the tutorials. I've also duplicated the assets folder everywhere (silly, I know) and I still get the same error. I even added the absolute path of the image file and I still get the same error. This code runs under Linux just fine, so I honestly don't see how it can't work under Windows 8.1 64-bit. All libraries are linked and SFML runs just fine. I even compiled and ran the tutorial example and that ran fine too. I'm convinced that this is a SFML 2.3 bug.
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::Texture texture;
if (!texture.loadFromFile("assets/graphics/explorer.png"))
cerr << "Unable to load image!" << endl;
sf::Sprite sprite;
sprite.setTexture(texture);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
return 0;
}
This is how I load the image. Before you start pointing the finger at pointers I also tried them as raw variables, but I still get the same error. I've also checked the drawing method, but that isn't important right now because not even the image is being loaded. I might roll back to version 2.1 since that was the most stable version on my part.
Can anyone explain why on SFML 2.3 loading images has suddenly stopped working? :-)) Is there another dependency I'm supposed to also link to?