Hi! I'm new to SFML (and a bit of newbie at programming), and I'm currently reading the tutorials. I'm on the sprites tutorial and I'm stuck on the first example, it says:
sf::Texture texture;
if (!texture.loadFromFile("image.png"))
{
// error...
}
So I drew an image, named it image.png, saved it in the project folder and wrote this in my .cpp file:
#include <iostream>
#include <SFML\Graphics.hpp>
int main()
{
// create render window
sf::RenderWindow rmain(sf::VideoMode(800, 600), "My Window");
rmain.setFramerateLimit(30);
sf::Texture texture;
if (!texture.loadFromFile("image.png"))
{
std::cout << "Unable to load image from file" << std::endl;
}
// run program as long as windos is open
while (rmain.isOpen())
{
// check all the window's events that were triggered since the last iteration of loop
sf::Event event;
while (rmain.pollEvent(event))
{
// "close requested" event, close the windoe
if (event.type == sf::Event::Closed)
rmain.close();
}
// clear the window with black color
rmain.clear(sf::Color::Black);
// draw stuff here
// windoe.draw(..);
// end current frame
rmain.display();
}
return 0;
}
The error that I get is pretty crazy, it makes the console go all nuts while blips and bloops spill out from my computers alarm and I have no idea why this happens, the image is on the right place, I even moved it around the project folder in case it was misplaced, but to no avail.
Can someone please help me identify the problem and perhaps guide me through the proces of fixing it? Thanks.
Also, I did a search on the forums but I got errors every time I tried, so very sorry if this have been brought up times before.
Elias