[Openal] New member - Compiling OpenAL example on Macintosh
E. Wing
ewmailing at gmail.com
Fri Mar 13 17:40:57 PDT 2009
On Fri, Mar 13, 2009 at 3:08 PM, Cara Quinn <caraquinn at caraquinn.com> wrote:
> Hello all, -just joined this list, and have a newby question which I'm
> betting has been asked bunches o' times before. So my apologies in advance!
> :)
>
> I'm working in C++ and am trying to compile a basic OpenAL example via the
> command line with GCC on a Mac running Leopard 10.6.
>
> I'm obviously getting errors having to do with alut.h not being found and
> thusly, all of the alut functions not being available.
>
> NOw, I know that technically alut is no longer supported in OpenAL 1.1 and
> Apple is adhering to that spec so I'm not surprised I can't compile, but my
> question is this; What in the world am I to do about it?! :)
>
Don't use alut :)
You describe two different reasons you need alut:
1) To initialize OpenAL
2) To load a WAV file
For (1), you can do everything with OpenAL directly. You need to open a
device, and then create a context in the device you opened to render sound
into.
So typically (ignoring error checking):
ALCdevice* openal_device = alcOpenDevice(NULL);
ALCcontext* openal_context = alcCreateContext(openal_device, 0);
// you may also want to explicitly make the context current to make sure it
is active
alcMakeContextCurrent(openal_context);
For (2), there are lots of different things you can do.
- You can use Core Audio's native audio file loaders
- You can go find a 3rd party audio file loader
- You can write your own
- You can cheat and exploit symbols that are still in Apple's OpenAL
framework but are publicly not exposed in headers
For 3rd party, you have a lot of options. I personally like SDL_sound
because it handles a lot of different file formats with a single API and is
cross-platform. There is a 3rd party re-implementation of alut you can also
use, but it is API/ABI incompatible with Apple's OpenAL framework for
technical reasons so you must rename all the function names in the library
to use it safely. You can also code directly to a specific codec, e.g. ogg
vorbis. I've seem some tutorials that do this with OpenAL.
For cheating, you can try to access the old alut symbols in Apple's OpenAL
framework. For backwards compatibility, Apple left the old symbols in the
framework to not break legacy programs. But this is also the reason the new
3rd party alut isn't compatible. The old alut API was different on every
single platform, and the new 3rd party alut has different function
signatures so you will get symbol clashes. But if you don't care about
cross-platform compatibility or using 3rd party alut, then this is a quick
simple hack.
So I think I have an example doing this hack to get the LoadWAV function.
http://playcontrol.net/ewing/jibberjabber/waveinterference_opengl_sha.html
(Find the DMG link and download it. The source code is inside.)
Apple also has a Mac specific OpenAL example found on your hard disk at:
/Developer/Examples/CoreAudio/Services/OpenALExample/
(assuming default Xcode install)
The Apple example will show you the Core Audio file loaders I think.
- Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20090313/f207157e/attachment.html
More information about the Openal
mailing list