0
如何在不創建新線程的情況下在Qt窗口內運行遊戲循環?在Qt窗口中運行遊戲循環
我「RunFrame」的方法是這樣的:
void GameWindow::RunFrame()
{
// Update the game time.
gameTime.Update();
timeBehind += gameTime.TotalTime() - lastTime;
lastTime = gameTime.TotalTime();
while(timeBehind >= targetTimeStep)
{
Update();
timeBehind -= targetTimeStep;
}
Draw();
SwapBuffers();
}
正如你所看到的,它運行時就如同獲取調用每一個事件循環。有沒有一種方法可以讓我的窗口中的方法被稱爲每個事件循環?或者我應該重新設計Qt中定時器的循環?
是的,QTimer工作正常。謝謝。 – Ben