Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-04 00:54:30 +0000
committerStijn Buys <ingar@osirion.org>2008-02-04 00:54:30 +0000
commit840f9b8678f607aecc15d47bc77248c4ac8b8574 (patch)
treef90688ca7afabb8e4123e1a811dd168a86717a3c /src/client/application.cc
parent43b994017a560a2fa97894ebfe121375d6614b6f (diff)
tweaked console
client status with timer and fps core connect/disconnect
Diffstat (limited to 'src/client/application.cc')
-rw-r--r--src/client/application.cc60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/client/application.cc b/src/client/application.cc
index 5822600..b7505a1 100644
--- a/src/client/application.cc
+++ b/src/client/application.cc
@@ -1,7 +1,7 @@
/*
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
+ 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
@@ -15,7 +15,8 @@
// C++ headers
#include <cmath>
-namespace client {
+namespace client
+{
extern "C" void func_con_toggle(std::stringstream &args)
{
@@ -33,16 +34,16 @@ void Application::init()
// initialize core
core::ApplicationInterface::init();
- con_debug << "Initializing client..." << std::endl;
+ con_print << "Initializing client..." << std::endl;
// Initialize the video subsystem
video.init();
if (!video.initialized) {
- quit(1);
- }
+ quit(1);
+ }
- // initialize input
- input.init();
+ // initialize input
+ input.init();
// register our engine functions
core::func_register("con_toggle", func_con_toggle);
@@ -52,41 +53,46 @@ void Application::run()
{
Uint32 chrono = SDL_GetTicks();
- while(true) {
- Uint32 current = SDL_GetTicks();
-
- // overflow protection ~49 days
- if (current < chrono) {
- chrono = current;
- }
+ while (true) {
+ Uint32 current = SDL_GetTicks();
- // update the game chronometers
- float elapsed = (float) ( current - chrono) / 1000.0f;
- chrono = current;
+ // overflow protection ~49 days
+ if (current < chrono) {
+ chrono = current;
+ }
- core::ApplicationInterface::frame(elapsed);
+ // update the core chronometer
+ float seconds = ((float)(current - chrono)) / 1000.0f;
+ frame(seconds);
+
+ // update the video chronometers and draw
+ video.frame(seconds);
+ if (seconds > 0)
+ current_fps = floorf(1/seconds);
+ else
+ current_fps = 9999;
- // update the video chronometers and draw
- video.draw(elapsed);
+ // process input
+ input.frame();
- // process input
- input.process();
- }
+ // update the main loop chronometer
+ chrono = current;
+ }
}
-void Application::shutdown()
+void Application::shutdown()
{
con_debug << "Shutting down client..." << std::endl;
console.flush();
input.shutdown();
console.flush();
-
+
video.shutdown();
console.flush();
- core::ApplicationInterface::shutdown();
+ core::ApplicationInterface::shutdown();
console.flush();
quit(0);