1

I just started using the SFML library and its fantastic. However when resizing a window by dragging the corner with my mouse i don't get the resize events until i release the mouse. This means i can't update my graphics until the mouse is released (game loop is on the gui thread) and is also causing a massive flood of events to come through of all the resize positions.

How can i make it so resizing doesn't block the thread?

1 Answer 1

3

Windows causes this. GetEvent() becomes blocking if you move or resize the window. (Another funny little reason to hate this OS...)

I have solved this with a separate event-polling thread. Take a look at this: (The interesting part for you is entirely in main.cpp.)

https://bitbucket.org/torokati44/netframework/src/93bdf20d0f65/main.cpp

2
  • Why do you use 2 event queues (event_buffer_a, event_buffer_b)? And why do you use std::queue instead of std::vector?
    – Truncheon
    Mar 31, 2011 at 13:17
  • This is called double buffering. Well... I'm not sure if it's really necessary after all, but it works now, and I have more important things to polish in this porject, so I don't mess with it right now. Yes, it can be done with only one buffer. The reason I made two might be that I thought the insertion would block, but only the GetEvent blocks, so the insertion after that is OK. Also, I don't think they have to be deque, queue would be enough. And I use queue because it's faster to pop/push than vector, because that's a linked list, and not a "C-style array" in the background.
    – Attila
    Mar 31, 2011 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.