if (!buffer.loadFromFile("sample.wav"))
{
cout << "error loading the sound file" << endl;
}
deathSound.setBuffer(this->buffer);
ive tried several different types of pathing and what im expecting to be default would be in my x64 folder inside my bin.If run from the IDE, it's "Project properties" > "Debugging" > "Working directory". This is usually set to $(ProjectDir) by default, I personnally replace it with $(TargetDir) so that it's the same directory as the created executable.
is there any way to get it to show more info when it fails?As already said, SFML prints error details to the standard error output (so it shows in the console by default).
if (!buffer.loadFromFile("death.wav"))
{
std::ofstream file("sfml-log.txt");
std::streambuf* previous = sf::err().rdbuf(file.rdbuf());
}
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>z
#include <iostream>
#include <fstream>
#include <sstream>
#include <streambuf>
using namespace std;
#ifdef _DEBUG
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-system-d.lib")
#pragma comment(lib, "sfml-graphics-d.lib")
#pragma comment(lib, "sfml-audio-d.lib")
#else
#pragma comment(lib, "sfml-window.lib")
#pragma comment(lib, "sfml-system.lib")
#pragma comment(lib, "sfml-graphics.lib")
#pragma comment(lib, "sfml-audio.lib")
#endif
int main()
{
sf::SoundBuffer buffer;
if (!buffer.loadFromFile("sounds/canary.wav"))
{
std::ofstream file("sfml-log.txt");
std::streambuf* previous = sf::err().rdbuf(file.rdbuf());
cerr << "i wantt more debuf info than this";
return -1;
}
sf::Sound death;
death.setBuffer(buffer);
death.play();
getchar();
return 0;
}