void MainLoop(void) { unsigned long l_start_time; unsigned long l_elapsed_time; unsigned long l_frame_time; //事件处理 FrameworkEvent(); // Rendering fps_count_rendering++; // Increase rendering FPS counter l_start_time = Framework_GetTicks(); //绘制 renderSystem.RenderDisplay(); renderSystem.RenderFpsUpdate(Framework_GetTicks()); // Elapsed time calculation l_elapsed_time=Framework_GetTicks()-l_start_time+remaining_time; // Elapsed time (we add also the previous remaining time) l_frame_time=l_elapsed_time / msecxdframe; // Frames quantity we must cycle for physics remaining_time=l_elapsed_time % msecxdframe; // Get the remaining time because we are working with integer values // Physics while (l_frame_time-->0) // Now do physics as many times as we need to match the elapsed time of the rendering phase { fps_count_physics++; // Increase physics FPS counter }//while (l_frame_time-->0) // Rendering and Physics FPS calculation if ((Framework_GetTicks()-last_ticks)>=1000) // Every second { last_ticks = Framework_GetTicks(); // Save the current ticks to catch the next second // Assings the current FPS count to the global variables fps_physics=fps_count_physics; fps_rendering=fps_count_rendering; // Clear the local counters fps_count_physics = 0; fps_count_rendering = 0; } }