diff options
Diffstat (limited to 'src/client/main.cpp')
| -rw-r--r-- | src/client/main.cpp | 162 |
1 files changed, 83 insertions, 79 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp index 13a52e4..2d30c70 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -70,7 +70,6 @@ void QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler) { } void UpdateElement(btRigidBody* TObject){ - if(TObject->getUserPointer() != NULL){ //UpdateRender(*Iterator); scene::ISceneNode *Node = static_cast<scene::ISceneNode *>((TObject)->getUserPointer()); @@ -87,82 +86,87 @@ void UpdateElement(btRigidBody* TObject){ } int main(int argc, char *argv[]){ - printf("Brok[en]gine Client"); - // Initialize bullet - phys_genesis(); - - //Create a new lua state, this gets shared everywhere - lua_State *state = luaL_newstate(); - L = state; - //Load the lua libraries - loadLLibs(state); - //Defined in initdevice.cpp, creates the irrlicht device - device = spawnIrrDevice(state); - if (!device) - return 1; - //Loads libraries for interfaceing with irrlicht - loadIrrLibs(state,device); - loadNetLibs(state); - printf("Loadded irr libs...\n"); - //Sets the global event handeler - GlobalEventReceiver ger = GlobalEventReceiver(device); - device->setEventReceiver(&ger); - int iErr = luaL_dofile(state,"../data/init.lua"); - if(iErr != 0){ - lua_error(state); - printf("Failed to open lua file:../data/guitest.lua\n"); - } - - //Load some bullet physics stuff - - //Load some menu - loadMenu("Some menu",device); - - IVideoDriver* driver = device->getVideoDriver(); - ISceneManager* smgr = device->getSceneManager(); - IGUIEnvironment* guienv = device->getGUIEnvironment(); - - device->setWindowCaption(L"Bork[en]gine Client"); - - printf("Everything registered, about to start running device!\n"); - - //u32 TimeStamp = irrTimer->getTime(), DeltaTime = 0; - //high_resolution_clock::time_point t1 = high_resolution_clock::now(); - while(device->run()){ - gameloop_net(L); - gameloop_phys(UpdateElement); - if(device->isWindowActive()){ - //high_resolution_clock::time_point now = high_resolution_clock::now(); - //duration<double> delta = now-t1; - //double steps = delta.count() * 100; - //UpdatePhysics(steps,UpdateElement); - //t1 = now; - driver->beginScene(true, true, SColor(255,100,101,140)); - - smgr->drawAll(); - guienv->drawAll(); - - driver->endScene(); - }else{ - device->yield(); - } - lua_getglobal(state,"GAME");//{} - lua_getfield(state,-1,"tick");//{},function_tick() - if(!lua_isnil(state,-1)){ - lua_call(state,0,0); - lua_pop(state,1); - }else{ - lua_pop(state,2); - } - } - printf("Closeing lua state...\n"); - //lua_close(state); - //printf("clearing objects...\n"); - //ClearObjects(World,Objects,RemoveISceneNode); //Clearing objects must be done after we droped the device. - phys_shutdown(RemoveISceneNode); - - device->drop(); - printf("droped device\n"); - - return 0; + printf("Brok[en]gine Client"); + // Initialize bullet + phys_genesis(); + + //Create a new lua state, this gets shared everywhere + lua_State *state = luaL_newstate(); + L = state; + //Load the lua libraries + loadLLibs(state); + //Defined in initdevice.cpp, creates the irrlicht device + device = spawnIrrDevice(state); + if (!device) + return 1; + //Loads libraries for interfaceing with irrlicht + loadIrrLibs(state,device); + loadNetLibs(state); + printf("Loadded irr libs...\n"); + //Sets the global event handeler + GlobalEventReceiver ger = GlobalEventReceiver(device); + device->setEventReceiver(&ger); + int iErr = luaL_dofile(state,"../data/init.lua"); + if(iErr != 0){ + lua_error(state); + printf("Failed to open lua file:../data/guitest.lua\n"); + } + + //Load some bullet physics stuff + + //Load some menu + loadMenu("Some menu",device); + + IVideoDriver* driver = device->getVideoDriver(); + ISceneManager* smgr = device->getSceneManager(); + IGUIEnvironment* guienv = device->getGUIEnvironment(); + + device->setWindowCaption(L"Bork[en]gine Client"); + + printf("Everything registered, about to start running device!\n"); + + //u32 TimeStamp = irrTimer->getTime(), DeltaTime = 0; + //high_resolution_clock::time_point t1 = high_resolution_clock::now(); + while(device->run()){ + printf("Game loop:\n"); + gameloop_net(L); + printf("Update phys:\n"); + gameloop_phys(UpdateElement); + if(device->isWindowActive()){ + //high_resolution_clock::time_point now = high_resolution_clock::now(); + //duration<double> delta = now-t1; + //double steps = delta.count() * 100; + //UpdatePhysics(steps,UpdateElement); + //t1 = now; + printf("beginscene\n"); + driver->beginScene(true, true, SColor(255,100,101,140)); + printf("scene drawAll\n"); + smgr->drawAll(); + printf("gui drawAll\n"); + guienv->drawAll(); + printf("scene end\n"); + driver->endScene(); + }else{ + device->yield(); + } + lua_getglobal(state,"GAME");//{} + lua_getfield(state,-1,"tick");//{},function_tick() + printf("Tick\n"); + if(!lua_isnil(state,-1)){ + lua_call(state,0,0); + lua_pop(state,1); + }else{ + lua_pop(state,2); + } + } + printf("Closeing lua state...\n"); + //lua_close(state); + //printf("clearing objects...\n"); + //ClearObjects(World,Objects,RemoveISceneNode); //Clearing objects must be done after we droped the device. + phys_shutdown(RemoveISceneNode); + + device->drop(); + printf("droped device\n"); + + return 0; } |
