Hello,
I'm rather experienced programming-wise. I am completely new, however, to IDEs, linking, and other such facets of software development. I've recently found out about SFML and decided to use it to learn about such processes.
My OS is Windows 8 64-bit, and I am using SFML with MinGW in CodeBlocks.
I've had experience using the command line MinGW g++ compile, and would've actually prefered using SFML in that, but learning about linking and other such things seemed was becoming a headache to figure out. So, instead, I set up SFML to work within CodeBlocks.
I've set up a test project, using only a Release build, which can compile and run fine. My problem, however, is figuring out how to access external files with SFML. I'm trying to run code provided on the SFML website, but am having problems loading an image.
Here is my code:
int main()
{
sf::RenderWindow window(sf::VideoMode(320, 320), "Test");
sf::Texture texture;
if (!texture.loadFromFile("image.png"))
return -1;
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;
}
The process is always terminated with status -1, so I'm assuming loadFromFile is always returning false.
My project directory is:
C:\Users\<name>\Documents\CodeBlocks Projects\Test
I've put "image.png" in:
"C:\Users\<name>\Documents\CodeBlocks Projects\Test\"
as well as in:
C:\Users\<name>\Documents\CodeBlocks Projects\Test\bin\Release\
but the program still throws the error.
I've tried to do research, and the only thing I thought would be the problem would be CodeBlock's "working directory" for the project, which I've tried setting to "bin\Release", but I have not met any success. Aside from that, my search did not yield that helped me fix the problem.
Am I using the function incorrectly, or is there some setting I missed somewhere?
Also, is there a way, using CodeBlocks, that I can package and access files, such as images, within the executable itself?
Thanks for any help,
Noah