SFML community forums
Help => Audio => Topic started by: Giovanni on May 06, 2011, 12:31:30 pm
-
Hello,
I'm trying to make a soundmanager using sfml audio, but I'm having some problems on the loading. I searched in this website and tried to do everything of what you said, but still doesn't work :(
Here's the loading:
int SoundManager::LoadSound(string strFileName)
{
sf::SoundBuffer *buffer = new sf::SoundBuffer();
if (!buffer->LoadFromFile(strFileName))
{
buffer->~SoundBuffer();
return -1;
}
for (size_t i = 0; i < m_buffers.size(); i++)
{
if (!m_buffers[i])
{
m_buffers[i] = buffer;
return i;
}
}
m_buffers.push_back(buffer);
return m_buffers.size() - 1;
//return 0;
}
if I made a really stupid mistake, please don't bother me, I'm a newbie as a programmer so be patient. :oops:
-
Where does it crash? (use the debugger -- F5)
buffer->~SoundBuffer();
You must never call a destructor explicitely. Here you must call delete, since you allocated the object with new.
-
buffer->~SoundBuffer();
You must never call a destructor explicitely. Here you must call delete, since you allocated the object with new.
thanks :}
anyway it crashes here:
if (!buffer->LoadFromFile(strFileName))
I'm compiling in release mode, the libs to use are sfml-audio-s.lib and sfml-system-s.lib, aren't they?
Because I think I messed up the vcpp configurations. :S
-
I'm compiling in release mode, the libs to use are sfml-audio-s.lib and sfml-system-s.lib, aren't they?
Yes.
You should compile in debug mode and run the debugger, it will tell you what's wrong ;)
Also, make sure that your version of Visual Studio matches the one of the libs that you're using (for example VC++ 2010 can't use VC++ 2008 libraries).
-
I'm compiling in release mode, the libs to use are sfml-audio-s.lib and sfml-system-s.lib, aren't they?
Yes.
You should compile in debug mode and run the debugger, it will tell you what's wrong ;)
Also, make sure that your version of Visual Studio matches the one of the libs that you're using (for example VC++ 2010 can't use VC++ 2008 libraries).
I made it!
you're the best man, thank you! :D
-
What was the problem?
-
What was the problem?
vc++2010, I had to compile the libs again
thank you,
your sfml is just awesome! :D