Reputation: 124
I am currently working on a game using OpenGL and C++ and wanted to start using SFML to implement audio. After some library linking aggravation, I got everything set up. However, SFML will not load audio files like shown in the tutorials.
The pertinent code so far is simply this:
#include <SFML/Audio.hpp>
...
sf::SoundBuffer buffer;
buffer.loadFromFile("resources/LaserShot.wav"); // That is the correct directory
And I get this in our console output (the game continues normally)
Failed to open sound file "resources/LaserShot.wav" (couldn't open stream)
Am I doing something wrong?
Upvotes: 0
Views: 2298
Reputation: 11
Do you also have this in release folder? If you're running it in release mode it might not be able to find it if it's not in the release folder in a folder named the same
Upvotes: 0
Reputation: 77304
// That is the correct directory
No, it's not.
You can check the source here: https://github.com/SFML/SFML/blob/master/src/SFML/Audio/SoundFileFactory.cpp#L74
The file was not found. Plain and simple.
Check your current directory and make sure your path is relative to that.
Upvotes: 2