|
|
if test x"$use_static_openal" = x"yes"; then | if test x"$use_static_openal" = x"yes"; then |
LIBS="$LIBS /usr/local/lib/libopenal.a" | LIBS="$LIBS /usr/local/lib/libopenal.a" |
else | else |
LIBS="$LIBS `$OPENAL_CONFIG --libs`" |
LIBS="$LIBS `$OPENAL_CONFIG --libs` -lalut" |
fi | fi |
| |
CFLAGS="$CFLAGS `$OPENAL_CONFIG --cflags`" | CFLAGS="$CFLAGS `$OPENAL_CONFIG --cflags`" |
|
|
SoundBuffer(fileName), | SoundBuffer(fileName), |
buffer_(0) | buffer_(0) |
{ | { |
unsigned int error; |
if ((buffer_ = alutCreateBufferFromFile(fileName)) == AL_NONE) |
|
|
// Create a buffer |
|
alGetError(); |
|
alGenBuffers(1, &buffer_); |
|
if ((error = alGetError()) != AL_NO_ERROR) |
|
{ |
|
return; |
|
} |
|
|
|
// Load WAV |
|
void *data; |
|
ALenum format; |
|
ALsizei size; |
|
ALsizei freq; |
|
ALboolean loop; |
|
|
|
#ifdef __DARWIN__ |
|
alutLoadWAVFile((ALbyte*) fileName,&format,&data,&size,&freq); |
|
#else |
|
alutLoadWAVFile((ALbyte*) fileName,&format,&data,&size,&freq,&loop); |
|
#endif |
|
|
|
if ((error = alGetError()) != AL_NO_ERROR) |
|
{ |
|
return; |
|
} |
|
|
|
// Load WAV into buffer |
|
alBufferData(buffer_,format,data,size,freq); |
|
if ((error = alGetError()) != AL_NO_ERROR) |
|
{ |
|
return; |
|
} |
|
|
|
// Delete WAV memory |
|
alutUnloadWAV(format,data,size,freq); |
|
if ((error = alGetError()) != AL_NO_ERROR) |
|
{ | { |
return; | return; |
} | } |
|
|
#include <sound/PlayingSoundSource.h> | #include <sound/PlayingSoundSource.h> |
#include <AL/al.h> | #include <AL/al.h> |
#include <AL/alc.h> | #include <AL/alc.h> |
|
#include <AL/alut.h> |
#include <algorithm> | #include <algorithm> |
| |
Sound *Sound::instance_ = 0; | Sound *Sound::instance_ = 0; |
|
|
totalSources_.push_back(source); | totalSources_.push_back(source); |
availableSources_.push_back(source); | availableSources_.push_back(source); |
} | } |
|
alutInitWithoutContext(NULL, NULL); |
| |
init_ = true; | init_ = true; |
return init_; | return init_; |