[Openal] Why do I need alut?

Chris Robinson chris.kcat at gmail.com
Sat May 9 21:19:41 PDT 2009


On Saturday 09 May 2009 8:57:55 pm bpazolli wrote:
> 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.

Hi.

alutInit opens a device and sets up a context for you, which is needed to work 
with the sources, buffers, and listener functions (basically all the non-alc* 
functions). alutExit the closes that device. You can replace alutInit in your 
code with this:

ALCdevice *device = alcOpenDevice(NULL);
ALCcontext *context = alcCreateContext(device, NULL);
alcMakeContextCurrent(context);

And you can replace alutExit with this:

ALCcontext *context = alcGetCurrentContext();
ALCdevice *device = alcGetContextsDevice(context);
alcDestroyContext(context);
alcCloseDevice(device);

Hope that helps. :)


More information about the Openal mailing list