Hi all! I have problem with loading this image onto the screen so I can see it. Here is my code if it is anything wrong with it:
Yes, I have the image in the directory and I know it is in a .png format. The CMD Window doesn't give me any error. But the window won't show the image. I'm using CodeBlocks and when I read the tutorial it said:
but when you launch your program from your IDE (Visual Studio, Code::Blocks, ...) the working directory is sometimes set to the project directory instead. This can generally be changed easily in the project settings.
And if that is the problem where do I find "project settings" in CodeBlocks? I didn't found it when I clicked on the project tab
#include <iostream>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "Window");
sf::Event event;
while (window.isOpen())
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear(sf::Color::Black);
sf::Texture texture;
if (!texture.loadFromFile("image.png"))
{
cout << "Could not load image.png" << endl;
}
window.display();
}
return 0;
}