]> git.tdb.fi Git - libs/al.git/blobdiff - source/listener.cpp
Make sound format support optional
[libs/al.git] / source / listener.cpp
index e341221156ee0b757f6e88e5fd0dccab6df5743a..00751488f2b44e464cfde234ddc8a4033b73d4b3 100644 (file)
@@ -1,38 +1,53 @@
-/* $Id$
-
-This file is part of libmspal
-Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "listener.h"
 
 namespace Msp {
 namespace AL {
 
-void Listener::attribute(ALenum attr, float v)
+Listener::Listener()
 {
-       alListenerf(attr, v);
+       orientation[0] = 0;
+       orientation[1] = 0;
+       orientation[2] = -1;
+       orientation[3] = 0;
+       orientation[4] = 1;
+       orientation[5] = 0;
 }
 
-void Listener::attribute(ALenum attr, float v0, float v1, float v2)
+Listener &Listener::instance()
 {
-       alListener3f(attr, v0, v1, v2);
+       static Listener listener;
+       return listener;
 }
 
-void Listener::attribute(ALenum attr, const float *v)
+void Listener::set_position(float x, float y, float z)
 {
-       alListenerfv(attr, v);
+       alListener3f(AL_POSITION, x, y, z);
 }
 
-void Listener::set_position(float x, float y, float z)
+void Listener::set_forward_direction(float x, float y, float z)
+{
+       orientation[0] = x;
+       orientation[1] = y;
+       orientation[2] = z;
+       alListenerfv(AL_ORIENTATION, orientation);
+}
+
+void Listener::set_up_direction(float x, float y, float z)
+{
+       orientation[3] = x;
+       orientation[4] = y;
+       orientation[5] = z;
+       alListenerfv(AL_ORIENTATION, orientation);
+}
+
+void Listener::set_velocity(float x, float y, float z)
 {
-       attribute(AL_POSITION, x, y, z);
+       alListener3f(AL_VELOCITY, x, y, z);
 }
 
 void Listener::set_gain(float g)
 {
-       attribute(AL_GAIN, g);
+       alListenerf(AL_GAIN, g);
 }
 
 } // namespace AL