Fix Windows OpenGL: Fallback to non-sRGB when sRGB not supported#221
Conversation
|
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: - 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
ad4150c to
18e1eaa
Compare
|
I think the ideal solution would be to chuck GL context creation out of Baseview and just use However, that ideal solution requires a breaking change (and probably more discussion), so I'm putting that aside and looking at this only for bug-fixing in the context of releasing v0.1. 🙂 I have yet to still test this on my end, but I much prefer this fallback approach compared to the one you implemented in #222, for two reasons:
I'll report back with my testing, and will close #222 in favor of this PR. 🙂 |
prokopyl
left a comment
There was a problem hiding this comment.
Code wise this looks good to me! 🙂
|
Can confirm this works as intended, both on Wine and on native Windows. Thank you for this PR, as well for the in-depth investigation, it is much appreciated! 🙂 |
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: