diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index fff731fa4..4c179197d 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -520,6 +520,9 @@ namespace UserConfigParams /** True if physics debugging should be enabled. */ PARAM_PREFIX bool m_physics_debug PARAM_DEFAULT( false ); + /** True if fps should be printed each frame. */ + PARAM_PREFIX bool m_fps_debug PARAM_DEFAULT(false); + /** True if slipstream debugging is activated. */ PARAM_PREFIX bool m_slipstream_debug PARAM_DEFAULT( false ); diff --git a/src/main.cpp b/src/main.cpp index 59c219942..1c0b5ed54 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -762,6 +762,8 @@ int handleCmdLine() UserConfigParams::m_rendering_debug=true; if(CommandLine::has("--ai-debug")) AIBaseController::enableDebug(); + if (CommandLine::has("--fps-debug")) + UserConfigParams::m_fps_debug = true; if(UserConfigParams::m_artist_debug_mode) { diff --git a/src/main_loop.cpp b/src/main_loop.cpp index b724fb27a..eff144c97 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -67,6 +67,24 @@ float MainLoop::getLimitedDt() { m_curr_time = device->getTimer()->getRealTime(); dt = (float)(m_curr_time - m_prev_time); + const World* const world = World::getWorld(); + if (UserConfigParams::m_fps_debug && world) + { + const LinearWorld *lw = dynamic_cast(world); + if (lw) + { + Log::verbose("fps", "time %f distance %f dt %f fps %f", + lw->getTime(), + lw->getDistanceDownTrackForKart(0), + dt*0.001f, 1000.0f / dt); + } + else + { + Log::verbose("fps", "time %f dt %f fps %f", + world->getTime(), dt*0.001f, 1000.0f / dt); + } + + } // don't allow the game to run slower than a certain amount. // when the computer can't keep it up, slow down the shown time instead