From 6c8446cddb37df732fc9e5fc21f98e31968ce634 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 1 Feb 2008 19:34:47 +0000 Subject: interface cleanup --- src/client/application.cc | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/client/application.cc (limited to 'src/client/application.cc') diff --git a/src/client/application.cc b/src/client/application.cc new file mode 100644 index 0000000..03dda2f --- /dev/null +++ b/src/client/application.cc @@ -0,0 +1,84 @@ +/* + 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 { + +void Application::quit(int status) +{ + SDL_Quit(); + exit(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(); +} + +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; + + 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; + + input.shutdown(); + + video.shutdown(); + + core::ApplicationInterface::shutdown(); + + quit(0); + +} + +} -- cgit v1.2.3