I have an SFML programme using window.setFramerateLimit() to determine the time step of the game.

I have a game loop that looks like this:

while (running)



Where sUserInput() contains the SFML while event loop which empties the windows event queue via window.pollEvent(), setting flags that sUpdate() process and then reflect in changes to the game state.

sRender() calls window.draw() on every entity in the game.

My simplistic understanding of game time steps is that with window.setFramerateLimit(1), SFML would wait for one second and fill up the window event queue with user events detected in that time (e.g. keypresses, key releases).

The game loop would then loop through the queue, updating the game state and redrawing.

Assuming the game loop always takes 0 seconds to execute, SFML (after displaying the new scene to the user) immediately restarts the one second timer, allowing the user to respond.

My questions are:

Is this right?

If so, is there a one second window, before the first game loop executes, where SFML is recording user events, such that the user could move their player character before the first frame is drawn to the screen?

I am guessing I am missing some fairly fundamental steps in how SFML works, if anyone could set me straight I would really appreciate that.


1 Answer 1


Is this right?

I believe the fundamentals of the question were correct.

is there a one second window, before the first game loop executes, where SFML is recording user events

I don't think so, no.

setFrameLimit(x) instructs SFML (if needed) to call sf::sleep after each call to window.display(), to ensure that each frame is displayed to the user for 1x seconds. Therefore, as window.display() is called in sRender() in the example, which is called after sUserInput(), there is no delay and for the first frame no user input is handled.

I am guessing that whilst the thread handling drawing is sleeping, the rest of the process remains awake, so user input can be captured for the full duration of each frame. If I am wrong please correct.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .