Fix Windows OpenGL: Fallback to non-sRGB when sRGB not supported#221
Fix Windows OpenGL: Fallback to non-sRGB when sRGB not supported#221john-parton wants to merge 1 commit intoRustAudio:masterfrom
Conversation
Previously, if sRGB framebuffer was requested but not available on Windows, the pixel format selection would fail silently with num_formats=0, leading to undefined behavior with an invalid pixel format. This commit adds: - Proper validation that wglChoosePixelFormatARB found a matching format - Graceful fallback: retry without sRGB if initial request fails - Warning message to inform users when falling back to non-sRGB
|
This resolves #220 It's a relatively simple workaround. As far as I can tell, the spec doesn't really say what happens if you use I didn't check the behavior on MacOS or Linux, as I wanted to keep the scope of this low, but there may be a similar issue. |
|
It looks like the behavior under linux to is to return as an error: Lines 190 to 192 in 237d323 I think probably it would be better if Windows behaved the same and then I guess whatever downstream libraries from here would have to handle that gracefully by explicitly re-initializing. |
|
My preference is that this pull request be seriously considered, but I have provided a minimal alternate of propagating the error to the user here: #222 I'm not sure that pull request could even be considered done, but it's there if we want to pivot. |
Previously, if sRGB framebuffer was requested but not available on Windows, the pixel format selection would fail silently with num_formats=0, leading to undefined behavior with an invalid pixel format.
This commit adds: