]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/sample_openal.hxx
Update the code a bit more, add a function to retreive the last error string and...
[simgear.git] / simgear / sound / sample_openal.hxx
index 8646e60d8e484512f2b61366b88404e520ded0dd..6ed815d51ac54697f9e88d95467251ffaac520a0 100644 (file)
@@ -2,7 +2,7 @@
 // 
 // Written by Curtis Olson, started April 2004.
 //
-// Copyright (C) 2004  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2004  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -74,6 +74,10 @@ private:
     // A constant offset to be applied to the final source_pos
     ALfloat offset_pos[3];
 
+    // The orientation of the sound (direction and cut-off angles)
+    ALfloat direction[3];
+    ALfloat inner, outer, outergain;
+
     // Velocity of the source sound.
     ALfloat source_vel[3];
 
@@ -237,6 +241,23 @@ public:
         alSourcefv( source, AL_POSITION, final_pos );
     }
 
+    /**
+     * Set the orientation of the sound source, both for direction
+     * and audio cut-off angles.
+     */
+    inline void set_orientation( ALfloat *dir, ALfloat inner_angle=360.0,
+                                               ALfloat outer_angle=360.0,
+                                               ALfloat outer_gain=0.0)
+    {
+        inner = inner_angle;
+        outer = outer_angle;
+        outergain = outer_gain;
+        alSourcefv( source, AL_DIRECTION, dir);
+        alSourcef( source, AL_CONE_INNER_ANGLE, inner );
+        alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
+        alSourcef( source, AL_CONE_OUTER_GAIN, outergain );
+    }
+
     /**
      * Set velocity of sound source (uses same coordinate system as opengl)
      */