diff options
author | sanikoyes <sanikoyes@163.com> | 2014-04-06 21:52:47 +0800 |
---|---|---|
committer | sanikoyes <sanikoyes@163.com> | 2014-04-06 21:52:47 +0800 |
commit | 77a840e350668a9c80b1e63b9b73aac44221c53b (patch) | |
tree | 40d2115e639bdc72a61811ac4f2fb0f04ec8eb7f /main/main.cpp | |
parent | 14bbdcb139b35e6d206df1ab3176d34245b72329 (diff) | |
parent | ded365031ede27b7a6efef59bc886343f58d310b (diff) |
Merge branch 'master' into hotfix-android-unicode-ime-input
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/main/main.cpp b/main/main.cpp index 7d19c2ebcf..64d16d452c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -577,12 +577,15 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas video_mode.height=globals->get("display/height"); if (use_custom_res && globals->has("display/fullscreen")) video_mode.fullscreen=globals->get("display/fullscreen"); + if (use_custom_res && globals->has("display/resizable")) + video_mode.resizable=globals->get("display/resizable"); GLOBAL_DEF("display/width",video_mode.width); GLOBAL_DEF("display/height",video_mode.height); GLOBAL_DEF("display/fullscreen",video_mode.fullscreen); + GLOBAL_DEF("display/resizable",video_mode.resizable); if (rtm==-1) { rtm=GLOBAL_DEF("render/thread_model",OS::RENDER_THREAD_SAFE); } @@ -648,7 +651,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas OS::get_singleton()->set_screen_orientation(OS::SCREEN_LANDSCAPE); } - OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("display/target_fps",60)); + OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/fixed_fps",60)); + OS::get_singleton()->set_target_fps(GLOBAL_DEF("application/target_fps",0)); if (!OS::get_singleton()->_verbose_stdout) //overrided OS::get_singleton()->_verbose_stdout=GLOBAL_DEF("debug/verbose_stdout",false); @@ -1210,6 +1214,7 @@ bool Main::start() { } uint64_t Main::last_ticks=0; +uint64_t Main::target_ticks=0; float Main::time_accum=0; uint32_t Main::frames=0; uint32_t Main::frame=0; @@ -1295,7 +1300,6 @@ bool Main::iteration() { } } else { VisualServer::get_singleton()->flush(); // flush visual commands - } if (AudioServer::get_singleton()) @@ -1343,6 +1347,16 @@ bool Main::iteration() { OS::get_singleton()->delay_usec( OS::get_singleton()->get_frame_delay()*1000 ); } + int taret_fps = OS::get_singleton()->get_target_fps(); + if (taret_fps>0) { + uint64_t time_step = 1000000L/taret_fps; + target_ticks += time_step; + uint64_t current_ticks = OS::get_singleton()->get_ticks_usec(); + if (current_ticks<target_ticks) OS::get_singleton()->delay_usec(target_ticks-current_ticks); + current_ticks = OS::get_singleton()->get_ticks_usec(); + target_ticks = MIN(MAX(target_ticks,current_ticks-time_step),current_ticks+time_step); + } + return exit; } |