diff options
author | Stijn Buys <ingar@osirion.org> | 2008-02-01 19:34:47 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-02-01 19:34:47 +0000 |
commit | 6c8446cddb37df732fc9e5fc21f98e31968ce634 (patch) | |
tree | 25515ae78969e2f0ef216a5cbef8a650b217e8f8 /src/client/application.cc | |
parent | f794b9ee52293cefd6ac73fdf0d2a01c5388f057 (diff) |
interface cleanup
Diffstat (limited to 'src/client/application.cc')
-rw-r--r-- | src/client/application.cc | 84 |
1 files changed, 84 insertions, 0 deletions
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 <SDL/SDL.h> + +// C++ headers +#include <cmath> + +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); + +} + +} |