/* client/application.cc This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ // project headers #include "client/client.h" #include "client/application.h" #include "core/core.h" // SDL headers #include // C++ headers #include namespace client { extern "C" void func_con_toggle(std::stringstream &args) { console.toggle(); } void Application::quit(int status) { SDL_Quit(); core::ApplicationInterface::quit(status); } void Application::init() { // initialize core core::ApplicationInterface::init(); con_debug << "Initializing client..." << std::endl; // Initialize the video subsystem video.init(); if (!video.initialized) { quit(1); } // initialize input input.init(); // register our engine functions core::func_register("con_toggle", func_con_toggle); } void Application::run() { Uint32 chrono = SDL_GetTicks(); while(true) { Uint32 current = SDL_GetTicks(); // overflow protection ~49 days if (current < chrono) { chrono = current; } // update the game chronometers float elapsed = (float) ( current - chrono) / 1000.0f; chrono = current; core::ApplicationInterface::frame(elapsed); // update the video chronometers and draw video.draw(elapsed); // process input input.process(); } } void Application::shutdown() { con_debug << "Shutting down client..." << std::endl; console.flush(); input.shutdown(); console.flush(); video.shutdown(); console.flush(); core::ApplicationInterface::shutdown(); console.flush(); quit(0); } }