But the CPU and GPU work asynchronous, so why would the CPU wait if it only needs to add a command to the GPU's queue? Or does calling
display() imply you want it to display immediately rather than when it's finished?
To answer the question from the OP. No, it isn't abnormal to have a nested
while loop. A typical loop would look like
while (window.isOpen()) {
sf::Event ev;
while (window.pollEvent(ev)) {
// process events
}
}
And a couple of remarks:
- Try to avoid using global variables and #defines.
- Don't mix real-time input and events: sf::Keyboard::isKeyPressed(...) is real-time. This returns true if the key is pressed at that exact moment. event.key.code == sf::Keyboard::... returns true at least once inside the event loop if the key was pressed since the previous event loop.