Hello, I have just started using SFML, and also Visual studio...
So I was following a guide to load a single texture and create an sprite from a file... Probably the most simple tutorial ever... but I am having problems nonetheless.
My code based in the tutorial just bellow, I am currently using the C++14 and x64 libraries:
#include "stdafx.h"
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
sf::Event event;
//window creation
sf::RenderWindow MainWindow(sf::VideoMode(400, 300), "Window");
//texture creation
sf::Texture textureTest1;
system("dir");
//if (!textureTest1.loadFromFile("img\test.png")) {
if (!textureTest1.loadFromFile("test.png")) {
std::cout << "the texture does not load" << std::endl;
}
else {
std::cout << "the texture does load" << std::endl;
}
//Sprite creation
sf::Sprite sprtTest1(textureTest1);
while (MainWindow.isOpen()) {
while (MainWindow.pollEvent(event)) {
if (event.type == sf::Event::EventType::Closed)
MainWindow.close();
}
MainWindow.clear();
MainWindow.draw(sprtTest1);
MainWindow.display();
}
return 0;
}
For some reason loadFromFile() is unable to load the texture from the file, even when I am in the correct working directory. From what I have been able to read online the most likely issue seems to be that the picture cant be open for some reason, but if that was the case I should be getting an error message in the console, which I am not getting. I saw in another topic that u have to set the target subsystem to console in order to be able to see the messages, and I have done this (Image bellow) but it is still likely that I am missing something because I dont see any error message... in any case, "test.png" is a simple image I made in paint, which is a red square inside a green square.
For most of my life I have been using Linux, but now for work reasons I must use windows, so that also could be an issue.
Please let me know if u have any insights to my predicament, I would really appreciate the help.
Thank you.