SDL and GC

Mark Harviston infinull at gmail.com
Mon Mar 27 10:09:52 PST 2006


I'm using the SDL and D to make a simple 2D game.
I'm having trouble with loading Sounds
I'd like to do something like this:

class someobject {
static Mix_Chunk* sound_effect;
static this(){
sound_effect = Mix_LoadWAV("seffect.wav");
}
int draw(){
//..other code..//
if( Mix_PlayChannel( -1, sound_effect, 0 ) == -1 ) { assert(); }
//..more code..//
}
}


but that fails, the sound isn't loaded so I have to do:
class someobject {
static Mix_Chunk* sound_effect;
int draw(){
//..other code..//
if(sound_effect is null) {
sound_effect = Mix_LoadWAV("seffect.wav");
}
if( Mix_PlayChannel( -1, sound_effect, 0 ) == -1 ) { assert(); }
//..more code..//
}
}

do I need to declare the Mix_Chunks as auto?
Is this a GC problem?
Is this and SDL problem?
(for the record I have the same problem with fonts)
I honestly had no clue where to ask this question, I figured this was as 
a good as any.
--Mark



More information about the Digitalmars-d-learn mailing list