SoundListener.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <sound/SoundListener.h>
00022 #include <sound/Sound.h>
00023 #ifdef __DARWIN__
00024 #include <OpenAL/al.h>
00025 #else
00026 #include <AL/al.h>
00027 #endif
00028 
00029 SoundListener::SoundListener()
00030 {
00031 }
00032 
00033 SoundListener::~SoundListener()
00034 {
00035 }
00036 
00037 Vector &SoundListener::getPosition()
00038 {
00039         static Vector position;
00040         if (!Sound::instance()->getInit()) return position;
00041 
00042         alGetListenerfv(AL_POSITION, position);
00043 
00044         return position;
00045 }
00046 
00047 void SoundListener::setPosition(Vector &position)
00048 {
00049         if (!Sound::instance()->getInit()) return;
00050 
00051         alListenerfv(AL_POSITION, position);
00052 }
00053 
00054 void SoundListener::setVelocity(Vector &velocity)
00055 {
00056         if (!Sound::instance()->getInit()) return;
00057 
00058         // Commented out to prevent linux crackling sounds
00059         //alListenerfv(AL_VELOCITY, velocity);
00060 }
00061 
00062 void SoundListener::setOrientation(Vector &o)
00063 {
00064         if (!Sound::instance()->getInit()) return;
00065 
00066         float orientation[6];
00067         orientation[0] = o[0];
00068         orientation[1] = o[1];
00069         orientation[2] = o[2];
00070         orientation[3] = 0.0f;
00071         orientation[4] = 0.0f;
00072         orientation[5] = 1.0f;
00073 
00074         alListenerfv(AL_ORIENTATION, orientation);
00075 }
00076 
00077 void SoundListener::setGain(float gain)
00078 {
00079         if (!Sound::instance()->getInit()) return;
00080 
00081         alListenerf(AL_GAIN, gain);
00082 }

Generated on Mon Feb 16 15:14:47 2009 for Scorched3D by  doxygen 1.5.3