Hmmm...That's what I was afraid of. Back during the winter when I was
thinking about a cross-platform engine I tried both SFML and SDL
extensively and was able to do what you did witht the sound objects by
using the sf::Sound::SetBuffer() function to reassign buffers. As you
pointed out it solves the problem of reassigning a sound object to a
new sound buffer, but it waistes a lot of memory in the process. Even
worse this kind of creating a buffer without the ability to destroy it
when you are done with it can lead to a major memory leak in your
program. That's the primary reason why I have stayed clear of SFML. It
doesn't necessarily use best code practices in doing some of the
things it does. For that reason I am strongly looking at using SDL
instead for my cross-platform games.
With SDL Mixer, for example, all of the sound chunks are pointers. If
you do something like
Mix_Chunk* g_pSound = NULL;
you have a global pointer here that remains in memory until you free
it with delete. To initialize this pointer simply do something like
Mix_LoadChunk(1, &g_pSound, "Sound/Some_File.wav");
which does three things. It initializes the pointer, asigns
Some_File.wav to it, and the pointer is asigned to the first audio
channel in the mixer. To free that pointer up use
g_pSound = NULL;
which frees up any memory used by that pointer and resets its state
back to null. If you then want to use another sound with that same
pointer simply use Mix_LoadChunk() again to reinitialize the pointer
with some new sound data. This to me seams a lot more memory safe and
much better way of handling audio than the way SFML does it.
If you wouldn't mind I'd be happy to create a Chopper Patrol clone
written in C++ using SDL rather than SFML. As SDL is cross-platform
too I think it would demonstrate both our aims but give potential
cross-platform developers another option or alternative to SFML with
some useful source code. What do you think?
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
All messages are archived and can be searched and read at
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.