Win32: Recover from invalid device context (DC)#3425
Win32: Recover from invalid device context (DC)#3425jkeller51 wants to merge 3 commits intoSFML:masterfrom
Conversation
Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
|
I really don't see what this is supposed to protect against. If In all the years I have been debugging OpenGL applications I have never once seen For all we know what you observed could have just been the result of some undefined behaviour or data race introduced somewhere else in your code that you eventually fixed and thus can't reproduce any longer. |
|
My application runs as a plugin to other software (digital audio workstations), so if what you're saying is true, it's possible that the other software was causing the problem and my tweak was just keeping my plugin chugging along anyway. Because it prints an error, I wouldn't say it's sweeping anything under the rug, but rather adds an additional check & recovers gracefully from an error state in the field. |
Description
This code change will check the result of
SwapBuffers(). IfSwapBuffers()fails, it will retrieve a new device context from Windows and proceed with the new context.I made this change on my fork in 2021, evidently facing an issue where the window wasn't redrawing in some scenario because the device context needed to be updated. I no longer recall the exact scenario so I can't currently reproduce, but I thought it might be useful anyway.
In short, in case Windows decides to give the window a new DC, this change allows SFML to recover from that without freezing up.