以下のコード構造http://www.koonsolo.com/news/dewitters-gameloop/ を使用して、設定されたfpsに基づいて処理するが、可能な限りレンダリング/描画するゲームループを設定しています。すべての処理能力/バッテリー寿命を使い果たしないように、描画fpsにキャップを実装するにはどうすればよいでしょうか。または、v-sync用に制限します。
const int TICKS_PER_SECOND = 60;
const int SKIP_TICKS = 1000000000 / TICKS_PER_SECOND;
const int MAX_FRAMESKIP = 5;
DWORD next_game_tick = GetTickCount();
int loops;
float interpolation;
bool game_is_running = true;
while( game_is_running ) {
loops = 0;
while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) {
update_game();
next_game_tick += SKIP_TICKS;
loops++;
}
interpolation = float( GetTickCount() + SKIP_TICKS - next_game_tick )
/ float( SKIP_TICKS );
display_game( interpolation );
}