I'm having trouble understanding the core concept of a game loop, and when the display actually happens. Could someone explain why this code (using SFML 2.0) successfully pops up a blank window:
void Game::Start(void) {
_mainWindow.Create(sf::VideoMode(1024, 768), "Otto");
_mainWindow.SetFramerateLimit(60);
while (!IsExiting()) {
sf::Event currentEvent;
while (_mainWindow.PollEvent(currentEvent)) {
}
_mainWindow.Clear(sf::Color(0,0,0));
_mainWindow.Display();
}
_mainWindow.Close();
}
But this code does not:
void Game::Start(void) {
_mainWindow.Create(sf::VideoMode(1024, 768), "Otto");
_mainWindow.SetFramerateLimit(60);
while (!IsExiting()) {
_mainWindow.Clear(sf::Color(0,0,0));
_mainWindow.Display();
}
_mainWindow.Close();
}
All that I removed is the event handling. Is there some tie in at the SFML level that actually triggers the display, or does the display happen immediately when .Display() is called?
Thanks for any help!