In the next OpenGL part I would like to focus on `WGL_ARB_pixel_format`. I was thinking that if a driver implements `wglGetPixelFormatAttribivARB` then it would be possible, in theory at least, to have a default implementation of `wglChoosePixelFormatARB` (and `wglGetPixelFormatAttribfvARB`) in `opengl32`. I am tempted to do this, instead of adding one more driver specific full implementation, although I am not yet sure if there any driver specific considerations or behaviors that would pose issues with such approach. Thoughts?
In term of potential issues, I see that winex11 wglChoosePixelFormatARB relies on glXChooseFBConfig while winemac implements it entirely itself. I don't know which one is better, we care about how this function behaves on Windows and in this case it might also be driver specific. Probably re-implemting the logic ourselves is okay, as long as we mimic whatever happens on Windows. It would be nice to confirm that the behavior is not completely different across drivers (or even if it is, maybe that means that it doesn't matter), ideally with tests.
Then, in theory, anything that factors code between drivers is good to have, the question might then be how to do it. There's several places where this can be done, opengl32 is one but there still, it could be on the PE or the unix side, or it could also be factored in win32u.
For this particular function, calling into the drivers wglGetPixelFormatAttribivARB for every attribute of every pixel format doesn't look very appealing if this has to cross the PE-unix boundaries each time. I can also imagine that the entire list of pixel formats and their attributes could be passed right away during GL initialization - assuming it doesn't change - and cached somewhere, in which case we could factor even wglGetPixelFormatAttribivARB.
Note that currently it's also not very convenient to do this in opengl32, because we may have two different GL drivers loaded at the same time. One from OSMesa, for memory DC, and another from the display drivers for display DCs. I think it would be nice if we could get rid of OSMesa and use the same GL driver for both, not completely sure how feasible this is but in the meantime it means that factoring things in opengl32 might still be a bit awkward.