- if(current_screen.get() == NULL)
- break;
-
- float elapsed_time = 1.0 / LOGICAL_FPS;
- ticks = SDL_GetTicks();
- if(ticks > fps_nextframe_ticks) {
- if(skipdraw == true) {
- // already skipped last frame? we have to slow down the game then...
- skipdraw = false;
- fps_nextframe_ticks -= (Uint32) (1000.0 / LOGICAL_FPS);
- } else {
- // don't draw all frames when we're getting too slow
- skipdraw = true;
- }
- } else {
- skipdraw = false;
- while(fps_nextframe_ticks > ticks) {
- /* just wait */
- // If we really have to wait long, then do an imprecise SDL_Delay()
- Uint32 diff = fps_nextframe_ticks - ticks;
- if(diff > 15) {
- SDL_Delay(diff - 10);
- }
- ticks = SDL_GetTicks();
- }
+void
+MainLoop::draw(DrawingContext& context)
+{
+ static Uint32 fps_ticks = SDL_GetTicks();
+ static int frame_count = 0;
+
+ current_screen->draw(context);
+ if(Menu::current() != NULL)
+ Menu::current()->draw(context);
+ if(screen_fade.get() != NULL)
+ screen_fade->draw(context);
+ Console::instance->draw(context);
+
+ if(config->show_fps)
+ draw_fps(context, fps);
+
+ // if a screenshot was requested, pass request on to drawing_context
+ if (screenshot_requested) {
+ context.take_screenshot();
+ screenshot_requested = false;
+ }
+ context.do_drawing();
+
+ /* Calculate frames per second */
+ if(config->show_fps)
+ {
+ ++frame_count;
+
+ if(SDL_GetTicks() - fps_ticks >= 500)
+ {
+ fps = (float) frame_count / .5;
+ frame_count = 0;
+ fps_ticks = SDL_GetTicks();