www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DerelictOrg and SDL_Mixer

reply "torea" <tetorea gmail.com> writes:
Hi all,

I'm playing a bit with D and SDL using DerelictOrg on debian 6. 
I've installed SDL2, SDL_mixer2 and the latest packages 
DerelictUtil and DerelictSDL2.
I can display some stuffs and interact with the keys.
Now I'm trying to add music and sounds but each time I try to 
access a function from SDL_mixer ( I tried with Mix_openAudio and 
Mix_LoadWav ), I get a segmentation fault.
These functions are defined in the mixer.d file in the 
DerelictSDL2 package but I guess I miss something concerning the 
link to the real sdl_mixer lib file.
Is there a specific way to install the sdl_mixer package with 
DerelictSDL2?
Nov 24 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Monday, 24 November 2014 at 21:19:40 UTC, torea wrote:
 Hi all,

 I'm playing a bit with D and SDL using DerelictOrg on debian 6. 
 I've installed SDL2, SDL_mixer2 and the latest packages 
 DerelictUtil and DerelictSDL2.
 I can display some stuffs and interact with the keys.
 Now I'm trying to add music and sounds but each time I try to 
 access a function from SDL_mixer ( I tried with Mix_openAudio 
 and Mix_LoadWav ), I get a segmentation fault.
 These functions are defined in the mixer.d file in the 
 DerelictSDL2 package but I guess I miss something concerning 
 the link to the real sdl_mixer lib file.
 Is there a specific way to install the sdl_mixer package with 
 DerelictSDL2?
It's a common error but did you load the Mixer and SDL libraries? DerelictSDL2Mixer.load(); DerelictSDL2.load(); And some code or output from gdb would be most helpful.
Nov 24 2014
parent reply "torea" <tetorea gmail.com> writes:
On Monday, 24 November 2014 at 23:27:58 UTC, Jack wrote:
 It's a common error but did you load the Mixer and SDL 
 libraries?
 DerelictSDL2Mixer.load();
 DerelictSDL2.load();

 And some code or output from gdb would be most helpful.
Oh.. I didn't know about the DerelictSDL2Mixer.load()! I thought the initialization of sdl_mixer was done with DerelictSDL2.load() Thanks very much!! I'll try this tonight! (And yes, I know it's better to post some code but I forgot to bring the source code..)
Nov 24 2014
parent reply Mike Parker <aldacron gmail.com> writes:
On 11/25/2014 9:26 AM, torea wrote:

 Oh.. I didn't know about the DerelictSDL2Mixer.load()!
 I thought the initialization of sdl_mixer was done with DerelictSDL2.load()
Every time you call DerelictFoo.load, you are loading exactly one library. You will never see a Derelict package that loads multiple libraries in one call.
Nov 25 2014
parent reply "torea" <tetorea gmail.com> writes:
On Tuesday, 25 November 2014 at 09:27:08 UTC, Mike Parker wrote:
 Every time you call DerelictFoo.load, you are loading exactly 
 one library. You will never see a Derelict package that loads 
 multiple libraries in one call.
ok, so basically, each time I want to access some specific functions imported like: import derelict.sdl2.foo; I have to load it like this? DerelictSDL2foo.load(); Is there some documentation about the usage of DerelictOrg with this kind of information? I couldn't find anything useful. The solution to my original problem was the missing line DerelictSDL2Mixer.load(); So thanks again, Jack! After that I also got a SDL_mixer error : No such device. This was solved by installing libasound-dev and libpulse-dev and recompiling SDL2. Now I have sound!!
Nov 25 2014
parent reply Mike Parker <aldacron gmail.com> writes:
On 11/26/2014 4:42 AM, torea wrote:

 ok, so basically, each time I want to access some specific functions
 imported like:
    import derelict.sdl2.foo;
 I have to load it like this?
    DerelictSDL2foo.load();
Don't think of it that way. Think of it this way: you have to load every library you want to use. SDL2_mixer is a library, SDL2_image is a library, SDL2_ttf is a library, and so on. You have to load them individually. DerelictSDL2 binds to SDL2, DerelictSDL2Mixer binds to SDL2_mixer and so on.
 After that I also got a SDL_mixer error : No such device.
 This was solved by installing libasound-dev and libpulse-dev and
 recompiling SDL2.
 Now I have sound!!
The Derelict packages are all just bindings to C libraries and nothing more. To use those libraries, you need to install their dependencies on each platform you need to use them on. If you don't know what the dependencies are, you should visit the website or support forums for that library.
Nov 25 2014
parent "torea" <tetorea gmail.com> writes:
On Wednesday, 26 November 2014 at 01:25:51 UTC, Mike Parker wrote:
 Don't think of it that way. Think of it this way: you have to 
 load every library you want to use. SDL2_mixer is a library, 
 SDL2_image is a library, SDL2_ttf is a library, and so on. You 
 have to load them individually. DerelictSDL2 binds to SDL2, 
 DerelictSDL2Mixer binds to SDL2_mixer and so on.
OK! Somehow I had overlooked the most obvious documentation on DerelictSDL2: the readme.md file on the github repository page which displays these informations.. Sorry!
 The Derelict packages are all just bindings to C libraries and 
 nothing more. To use those libraries, you need to install their 
 dependencies on each platform you need to use them on. If you 
 don't know what the dependencies are, you should visit the 
 website or support forums for that library.
Yes, it was an issue unrelated to D or DerelictOrg but still some problem encountered by clueless me on its quest to use SDL_Mixer functions with D.. This might be of some help for a beginner like me who had difficulties to find some straightforward documentation to set everything up. The SDL and SDL_mixer websites did not help much (..or I overlooked some stuffs again).
Nov 25 2014