1

When I resize the window for my C++ application and make circling motions (just drag the top-left corner a bunch), it causes a strange artefact.

enter image description here

When I let go of my mouse:

enter image description here

Essentially what's happening is the application pauses whilst the window is being resized. Is there a way around this?

EDIT: Thanks for closing my question guys...

If anyone miraculously finds this question, I was able to find my own "solution". Do yourself a favour and use freeGLUT rather than SDL2, works like a charm, the set-up is much easier too.

Halden Collier
  • 845
  • 7
  • 18
  • Possible duplicate of [How do I stop Windows from blocking the program during a window drag or menu button being held down?](https://stackoverflow.com/questions/18041622/) – genpfault Feb 10 '21 at 20:40
  • Also: [Bug 2077 - Windows: main thread is blocked when user resizes or moves a window](https://bugzilla.libsdl.org/show_bug.cgi?id=2077) – genpfault Feb 10 '21 at 20:40
  • Possible duplicate of [Keep window active while being dragged (SDL on Win32)](https://stackoverflow.com/questions/7106586/keep-window-active-while-being-dragged-sdl-on-win32) – genpfault Feb 10 '21 at 21:37

1 Answers1

1

Pretty much all window APIs(Win32, GLFW, etc) have some sort of PollEvents() function that takes all the events out of the event queue and processes them. For Win32, you have a callback function that gets called every event and you process them individually until the queue is empty. For GLFW you poll the events, then you read the state of a certain key from the updated input data (As I understand it). Regardless of the specific implementation for input, most PollEvents() functions become blocking when you either resize or move the window. What that means is that it will be constantly receiving events of type window resize or window move, even if there is no change. This causes the rendering to not update, which causes all sorts of weird stuff. The way around this is to put the PollEvents() function on a different thread than the update loop and call it repeatedly. Depending on what API you're using, there might be restrictions. For example, GLFW's PollEvents() function must be on the main thread, forcing the update loop to be on a separate thread. However, the idea is still the same across window APIs.

Ty Staszak
  • 115
  • 2
  • 11