lugre_sound_L.cpp

Go to the documentation of this file.
00001 #include "lugre_prefix.h"
00002 #include "lugre_sound.h"
00003 #include "lugre_luabind.h"
00004 
00005 extern "C" {
00006     #include "lua.h"
00007     #include "lauxlib.h"
00008     #include "lualib.h"
00009 }
00010 
00011 
00012 
00013 namespace Lugre {
00014 
00015 class cSoundSource_L : public cLuaBind<cSoundSource> { public:
00016     // implementation of cLuaBind
00017 
00019         virtual void RegisterMethods    (lua_State *L) { PROFILE
00020             #define REGISTER_METHOD(methodname) mlMethod.push_back(make_luaL_reg(#methodname,&cSoundSource_L::methodname));
00021             
00022             REGISTER_METHOD(Destroy);
00023             REGISTER_METHOD(SetPosition);
00024             REGISTER_METHOD(SetVelocity);
00025             REGISTER_METHOD(GetPosition);
00026             REGISTER_METHOD(GetVelocity);
00027             REGISTER_METHOD(Is3D);
00028             REGISTER_METHOD(IsPlaying);
00029             REGISTER_METHOD(IsPaused);
00030             REGISTER_METHOD(Play);
00031             REGISTER_METHOD(Pause);
00032             REGISTER_METHOD(Stop);
00033             REGISTER_METHOD(SetVolume);
00034             REGISTER_METHOD(GetVolume);
00035             REGISTER_METHOD(SetMinMaxDistance);
00036             REGISTER_METHOD(GetMinMaxDistance);
00037 
00038             #undef REGISTER_METHOD
00039         }
00040         
00041         // object methods exported to lua
00042 
00043         
00044         // SoundSource:SetMinMaxDistance(x)
00045         static int SetMinMaxDistance(lua_State *L) { PROFILE
00046             checkudata_alive(L)->SetMinMaxDistance(luaL_checknumber(L,2),luaL_checknumber(L,3));return 0;
00047         }
00048 
00049         // min,max = SoundSource:GetMinMaxDistance()
00050         static int GetMinMaxDistance(lua_State *L) { PROFILE
00051             float min,max;          
00052             checkudata_alive(L)->GetMinMaxDistance(min,max);
00053             lua_pushnumber(L,min);
00054             lua_pushnumber(L,max);
00055             return 2;
00056         }
00057 
00058         // SoundSource:SetVolume(x)
00059         static int SetVolume(lua_State *L) { PROFILE
00060             checkudata_alive(L)->SetVolume(luaL_checknumber(L,2));return 0;
00061         }
00062         
00063         // x = SoundSource:GetVolume()
00064         static int GetVolume(lua_State *L) { PROFILE
00065             float x;            
00066             x = checkudata_alive(L)->GetVolume();
00067             lua_pushnumber(L,x);
00068             return 1;
00069         }
00070         
00071 
00072         // SoundSource:SetPosition(x,y,z)
00073         static int SetPosition(lua_State *L) { PROFILE
00074             checkudata_alive(L)->SetPosition(luaL_checknumber(L,2),luaL_checknumber(L,3),luaL_checknumber(L,4));return 0;
00075         }
00076         
00077         // SoundSource:SetVelocity(x,y,z)
00078         static int SetVelocity(lua_State *L) { PROFILE
00079             checkudata_alive(L)->SetVelocity(luaL_checknumber(L,2),luaL_checknumber(L,3),luaL_checknumber(L,4));return 0;
00080         }
00081         
00082         // x,y,z = SoundSource:GetPosition()
00083         static int GetPosition(lua_State *L) { PROFILE
00084             float x = 0,y = 0,z = 0;            
00085             checkudata_alive(L)->GetPosition(x,y,z);
00086             lua_pushnumber(L,x);lua_pushnumber(L,y);lua_pushnumber(L,z);
00087             return 3;
00088         }
00089         
00090         // x,y,z = SoundSource:GetVelocity()
00091         static int GetVelocity(lua_State *L) { PROFILE
00092             float x = 0,y = 0,z = 0;            
00093             checkudata_alive(L)->GetVelocity(x,y,z);
00094             lua_pushnumber(L,x);lua_pushnumber(L,y);lua_pushnumber(L,z);
00095             return 3;
00096         }
00097 
00098         // bool = SoundSource:Is3D()
00099         static int Is3D(lua_State *L) { PROFILE lua_pushboolean(L,checkudata_alive(L)->Is3D());return 1;}
00100 
00101         // bool = SoundSource:IsPlaying()
00102         static int IsPlaying(lua_State *L) { PROFILE lua_pushboolean(L,checkudata_alive(L)->IsPlaying());return 1;}
00103 
00104         // bool = SoundSource:IsPaused()
00105         static int IsPaused(lua_State *L) { PROFILE lua_pushboolean(L,checkudata_alive(L)->IsPaused());return 1;}
00106 
00107         // SoundSource:Play()
00108         static int Play(lua_State *L) { PROFILE checkudata_alive(L)->Play();return 0;}
00109         // SoundSource:Pause()
00110         static int Pause(lua_State *L) { PROFILE checkudata_alive(L)->Pause();return 0;}
00111         // SoundSource:Stop()
00112         static int Stop(lua_State *L) { PROFILE checkudata_alive(L)->Stop();return 0;}
00113         
00115         static int  Destroy         (lua_State *L) { PROFILE
00116             delete checkudata_alive(L);
00117             return 0;
00118         }
00119         
00120         virtual const char* GetLuaTypeName () { return "lugre.SoundSource"; }
00121 };
00122 
00123 class cSoundSystem_L : public cLuaBind<cSoundSystem> { public:
00124     // implementation of cLuaBind
00125 
00127         virtual void RegisterMethods    (lua_State *L) { PROFILE
00128             #define REGISTER_METHOD(methodname) mlMethod.push_back(make_luaL_reg(#methodname,&cSoundSystem_L::methodname));
00129             
00130             lua_register(L,"CreateSoundSystem",     &cSoundSystem_L::CreateSoundSystem);
00131             
00132             REGISTER_METHOD(Destroy);
00133             REGISTER_METHOD(SetListenerPosition);
00134             REGISTER_METHOD(SetListenerVelocity);
00135             REGISTER_METHOD(GetListenerPosition);
00136             REGISTER_METHOD(GetListenerVelocity);
00137             REGISTER_METHOD(SetVolume);
00138             REGISTER_METHOD(GetVolume);
00139             REGISTER_METHOD(SetDistanceFactor);
00140             REGISTER_METHOD(GetDistanceFactor);
00141             REGISTER_METHOD(CreateSoundSource);
00142             REGISTER_METHOD(CreateSoundSource3D);
00143             REGISTER_METHOD(Step);
00144 
00145             #undef REGISTER_METHOD
00146         }
00147         
00148         // object methods exported to lua
00149 
00150         // CreateSoundSystem(name,frequency)
00151         static int CreateSoundSystem(lua_State *L) { PROFILE
00152             cSoundSystem* target = Lugre::CreateSoundSystem(luaL_checkstring(L,1),luaL_checkint(L,2));
00153             if(target)return CreateUData(L,target);
00154             else return 0;
00155         }
00156         
00157         // SoundSystem:SetVolume(x)
00158         static int SetVolume(lua_State *L) { PROFILE
00159             checkudata_alive(L)->SetVolume(luaL_checknumber(L,2));return 0;
00160         }
00161         
00162         // x = SoundSystem:GetVolume()
00163         static int GetVolume(lua_State *L) { PROFILE
00164             float x;            
00165             x = checkudata_alive(L)->GetVolume();
00166             lua_pushnumber(L,x);
00167             return 1;
00168         }
00169 
00170         // SoundSystem:SetDistanceFactor(x)
00171         static int SetDistanceFactor(lua_State *L) { PROFILE
00172             checkudata_alive(L)->SetDistanceFactor(luaL_checknumber(L,2));return 0;
00173         }
00174         
00175         // SoundSystem:Step()
00176         static int Step(lua_State *L) { PROFILE
00177             checkudata_alive(L)->Step();return 0;
00178         }
00179         
00180         // x = SoundSystem:GetDistanceFactor()
00181         static int GetDistanceFactor(lua_State *L) { PROFILE
00182             float x;            
00183             x = checkudata_alive(L)->GetDistanceFactor();
00184             lua_pushnumber(L,x);
00185             return 1;
00186         }       
00187 
00188         // SoundSystem:SetListenerPosition(x,y,z)
00189         static int SetListenerPosition(lua_State *L) { PROFILE
00190             checkudata_alive(L)->SetListenerPosition(luaL_checknumber(L,2),luaL_checknumber(L,3),luaL_checknumber(L,4));return 0;
00191         }
00192         
00193         // SoundSystem:SetListenerVelocity(x,y,z)
00194         static int SetListenerVelocity(lua_State *L) { PROFILE
00195             checkudata_alive(L)->SetListenerVelocity(luaL_checknumber(L,2),luaL_checknumber(L,3),luaL_checknumber(L,4));return 0;
00196         }
00197         
00198         // x,y,z = SoundSystem:GetListenerPosition()
00199         static int GetListenerPosition(lua_State *L) { PROFILE
00200             float x,y,z;            
00201             checkudata_alive(L)->GetListenerPosition(x,y,z);
00202             lua_pushnumber(L,x);lua_pushnumber(L,y);lua_pushnumber(L,z);
00203             return 3;
00204         }
00205         
00206         // x,y,z = SoundSystem:GetListenerVelocity()
00207         static int GetListenerVelocity(lua_State *L) { PROFILE
00208             float x,y,z;            
00209             checkudata_alive(L)->GetListenerVelocity(x,y,z);
00210             lua_pushnumber(L,x);lua_pushnumber(L,y);lua_pushnumber(L,z);
00211             return 3;
00212         }
00213         
00215         static int              CreateSoundSource       (lua_State *L) { PROFILE
00216             cSoundSource* target = 0;
00217             target = checkudata_alive(L)->CreateSoundSource(luaL_checkstring(L,2));
00218             return target ? cLuaBind<cSoundSource>::CreateUData(L,target) : 0;
00219         }
00220 
00222         static int              CreateSoundSource3D     (lua_State *L) { PROFILE
00223             cSoundSource* target = 0;
00224             target = checkudata_alive(L)->CreateSoundSource3D(luaL_checknumber(L,2),luaL_checknumber(L,3),luaL_checknumber(L,4),luaL_checkstring(L,5));
00225             return target ? cLuaBind<cSoundSource>::CreateUData(L,target) : 0;
00226         }
00227 
00229         static int  Destroy         (lua_State *L) { PROFILE
00230             delete checkudata_alive(L);
00231             return 0;
00232         }
00233         
00234         virtual const char* GetLuaTypeName () { return "lugre.SoundSystem"; }
00235 };
00236 
00237 
00239 void    cSoundSource::LuaRegister   (lua_State *L) { PROFILE
00240     cLuaBind<cSoundSource>::GetSingletonPtr(new cSoundSource_L())->LuaRegister(L);
00241     cLuaBind<cSoundSystem>::GetSingletonPtr(new cSoundSystem_L())->LuaRegister(L);
00242 }
00243 
00244 };

Generated on Wed May 23 06:00:15 2012 for cpp by  doxygen 1.5.6