1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Moved main loop to game engine class

This commit is contained in:
Ivan Savenko
2025-03-03 20:30:15 +00:00
parent 222b73bbcd
commit f8c1d217d4
3 changed files with 31 additions and 41 deletions

View File

@ -104,27 +104,33 @@ void GameEngine::fakeMouseMove()
});
}
void GameEngine::renderFrame()
[[noreturn]] void GameEngine::mainLoop()
{
for (;;)
{
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
engineUser->onUpdate();
handleEvents();
windows().simpleRedraw();
if (settings["video"]["showfps"].Bool())
drawFPSCounter();
screenHandlerInstance->updateScreenTexture();
windows().onFrameRendered();
ENGINE->cursor().update();
input().fetchEvents();
updateFrame();
screenHandlerInstance->presentScreenTexture();
framerate().framerateDelay(); // holds a constant FPS
}
}
screenHandlerInstance->presentScreenTexture();
framerate().framerateDelay(); // holds a constant FPS
void GameEngine::updateFrame()
{
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
engineUser->onUpdate();
handleEvents();
windows().simpleRedraw();
if (settings["video"]["showfps"].Bool())
drawFPSCounter();
screenHandlerInstance->updateScreenTexture();
windows().onFrameRendered();
ENGINE->cursor().update();
}
GameEngine::GameEngine()