10 #include <OpenAL/al.h> 
   39     ALCdevice* device = alcOpenDevice(
nullptr);
 
   40     ALCcontext* context = alcCreateContext(device, 
nullptr);
 
   41     alcMakeContextCurrent(context);
 
   43     if (alutInitWithoutContext(
nullptr, 
nullptr) == AL_FALSE) {
 
   51     alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
 
   54     glm::vec3 at(0.0f, 0.0f, -1.0f);
 
   55     glm::vec3 up(0.0f, 1.0f, 0.0f);
 
   70     if (alutExit() == AL_FALSE)
 
   85     if (alGetError() != AL_NO_ERROR) {
 
   92     if (alGetError() != AL_NO_ERROR) {
 
   99     if (alGetError() != AL_NO_ERROR) {
 
  104     glm::vec3 at(0.0f, 0.0f, -1.0f);
 
  105     glm::vec3 up(0.0f, 1.0f, 0.0f);
 
  120     unsigned int r = alutCreateBufferFromFileImage(buffer, length);
 
  142     if ((buffer < 0) || (buffer >= 
buffers.size())) {
 
  151     alGenSources(1, &
id);
 
  152     if (alGetError() != AL_NO_ERROR) {
 
  157     alSourcei(
id, AL_BUFFER, 
buffers.at(buffer));
 
  158     alSourcef(
id, AL_GAIN, volume);
 
  163         alSourcei(
id, AL_LOOPING, AL_TRUE);
 
  181     if ((source < 0) || (source >= 
sources.size())) {
 
  186     alSourcefv(
sources.at(source), AL_POSITION, &pos[0]);
 
  197     float orientation[6] = { at.x, at.y, at.z, up.x, up.y, up.z };
 
  198     alListenerfv(AL_POSITION, &pos[0]);
 
  199     alListenerfv(AL_ORIENTATION, orientation);
 
  202         alSourcefv(s, AL_POSITION, &pos[0]);
 
  218         if ((source >= 0) && (source < 
sources.size()))
 
  219             alSourcePlay(
sources.at(source));
 
  229     if ((source >= 0) && (source < 
sources.size()))
 
  230         alSourceStop(
sources.at(source));
 
  255         alListenerf(AL_GAIN, 
volume);
 
static void setEnabled(bool on)
static const float referenceDistance
static int loadBuffer(unsigned char *buffer, unsigned int length)
static glm::vec3 lastPosition
static LogLevel & get(int level)
OpenAL Sound Implementation. 
static void play(int source, bool atListener)
static const float soundTravelSectors
static int numSources(bool atListener)
static std::vector< unsigned int > listenerSources
static std::vector< unsigned int > sources
static void stop(int source)
static void setVolume(float vol)
static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up)
static std::vector< unsigned int > buffers
static int addSource(int buffer, float volume, bool atListener, bool loop)
static const float maxDistance
static int sourceAt(int source, glm::vec3 pos)