]> Dogcows Code - chaz/yoink/blobdiff - src/moof/application.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / application.cc
index 0da5bae4b449a989b878c427a541bd065d0ee00f..e0b73b78d9ac053e7a5f8805a2431acc4c730235 100644 (file)
@@ -1,15 +1,13 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
-#include <cstdlib>                                     // exit, srand
+#include <cstdlib>                     // exit, srand
 #include <boost/noncopyable.hpp>
 
 #include <SDL/SDL.h>
@@ -42,20 +40,19 @@ application::application(settings& settings) :
        settings.get("framerate", framerate);
        framerate = SCALAR(1.0) / framerate;
 
-       //timer::default_source().scale(SCALAR(0.76));
-
        //update_timer_.init(boost::bind(&application::dispatch_update,
-                                                                  //this, _1, _2),
-                                          //timestep_, timer::repeat);
+               //this, _1, _2), timestep_, timer::repeat);
        //add_timer(update_timer_);
        
        game_time_.reset(timestep_);
+       //game_time_.scale(SCALAR(0.5));
 
        draw_timer_.init(boost::bind(&application::dispatch_draw,
-                                                                this, _1, _2), framerate, timer::repeat);
+                               this, _1, _2), framerate, timer::repeat);
        add_timer(draw_timer_);
-}
 
+       //timer::default_source().scale(SCALAR(0.2));
+}
 
 void application::dispatch_update(timer& timer, scalar t)
 {
@@ -65,27 +62,23 @@ void application::dispatch_update(timer& timer, scalar t)
        {
                switch (event.type)
                {
-                       case SDL_KEYDOWN:
-
-                               if (event.key.keysym.sym == SDLK_ESCAPE &&
-                                               (SDL_GetModState() & KMOD_CTRL) )
-                               {
-                                       // emergency escape
-                                       log_warning("escape forced");
-                                       exit(1);
-                               }
-                               break;
-
-                       case SDL_VIDEORESIZE:
-
-                               video::current()->resize(event.resize.w, event.resize.h);
-                               break;
+               case SDL_KEYDOWN:
+                       if (event.key.keysym.sym == SDLK_ESCAPE &&
+                                       (SDL_GetModState() & KMOD_CTRL))
+                       {
+                               log_warning("escape forced");
+                               exit(1);
+                       }
+                       break;
+
+               case SDL_VIDEORESIZE:
+                       video::current()->resize(event.resize.w,
+                                       event.resize.h);
+                       break;
                }
-
                handle_event(event);
        }
 
-
        const int MAX_CONSECUTIVE_UPDATES = 15;
 
        log_debug("updating", timer.expiration(), "/", t);
@@ -96,9 +89,8 @@ void application::dispatch_update(timer& timer, scalar t)
        int i = 0;
        while (timestep_ <= accum_ && i < MAX_CONSECUTIVE_UPDATES)
        {
-               log_debug("UPDATING");
-               update(game_time_.ticks(), timestep_);
-               game_time_.step();
+               scalar dt = game_time_.step();
+               update(game_time_.ticks(), dt);
                accum_ -= timestep_;
        }
 
@@ -116,7 +108,7 @@ void application::dispatch_draw(timer& timer, scalar t)
 
        scalar alpha = accum_ * inverse_timestep_;
        
-       alpha = cml::clamp(alpha, SCALAR(-1.0), SCALAR(2.0));
+       //alpha = cml::clamp(alpha, SCALAR(-1.0), SCALAR(2.0));
        if (alpha < SCALAR(0.0)) log_warning("alpha:", alpha);
        else if (alpha > SCALAR(1.0)) log_warning("alpha:", alpha);
        else log_debug("alpha:", alpha);
@@ -125,9 +117,11 @@ void application::dispatch_draw(timer& timer, scalar t)
 
        scalar begin = timer::ticks();
        video::current()->swap(t);
-
        scalar duration = timer::ticks() - begin;
-       log_debug("flip duration:", duration);
+       log_debug("flip duration:", duration, begin, timer::ticks());
+
+       log_info("draw difference:", t - last_draw_);
+       last_draw_ = t;
 }
 
 
This page took 0.021313 seconds and 4 git commands to generate.