[Openal] Why do I need alut?

Jason Daly jdaly at ist.ucf.edu
Sat May 9 21:22:25 PDT 2009


bpazolli wrote:
> I have created this program which isn't quite working so I won't post the
> code. But in an older version that did work whenever I got rid of the
> '#include <al/alut.h>' line and the alutExit and alutInit calls. It would
> stop working. I was making my program off the basis of a tutorial example
> code that had alutLoadWAVFile & alutUnloadWAV calls and seeming that I got
> rid of them (i.e. I am not using a wav file anymore) I thought I could get
> rid of the alut stuff. Everything compiles fine with the alut stuff but when
> I run my program no sound comes out. It's a pretty basic program that just
> sets up buffers, sources and listeners and then provides some basic
> play/pause/stop playback controls. At the moment I just keep the alutExit &
> alutInit calls in and it runs fine but I'm interested in getting rid of them
> cause then I assume I can get rid of alut.dll with my program. I just don't
> know why I have to include them.
>   

alutInit/alutExit are only necessary if you're using ALUT elsewhere in 
your program.

Are you opening the sound device, and creating a context first?

device = alcOpenDevice(NULL);
context = alcCreateContext(device, NULL);
alcMakeContextCurrent(context);

... application code ...

alcMakeContextCurrent(NULL);
alcCloseContext(context);
alcCloseDevice(device);


The above code is minimal for clarity; real code should do some error 
checking to be sure the device and context are created correctly.  
Depending on your app, you might also want to use device enumeration to 
let your users choose from multiple audio devices.  See the OpenAL spec 
for more details.  You might also want to look at Creative's 
programmer's guide, which is organized more like a tutorial.

--"J"



More information about the Openal mailing list