Few fixes for WGL after recent updates
Hi,
This attempts to fix a few issues in WGL after the updates in the way how we realize GL contexts, namely:
- We are now using
g_clear_pointer()
to callwglDeleteContext()
, which means we must use the correct calling convention for it in particular for 32-bit builds up otherwise weird crashes occur. - We are now realizing WGL contexts earlier, so we must now really use a separate dummy
HWND
to set up a separate dummyHGLRC
, before we setup the "real" dummy HGLRC/HDC that we use to emulate surfaceless contexts. The reasoning is because we must useCS_OWNDC
for creatingHWND/HDC
s for GL usage, meaning thatGetDC()
calls from the sameHWND
will always return us the exact sameHDC
even ifDeleteDC()
was called on theHDC
, whereSetPixelFormat()
can only be called once on thatHDC
. This will also ensure the "real" dummy HGLRC/HDC use the correct pixel format asChoosePixelFormat()
andwglChoosePixelFormatARB()
can return different pixel formats aswglCoosePixelFormatARB()
is more fine-grained. - Also try to cut down on the number of times where we must setup a base
HGLRC
to create the real (Core and/or GL contexts setup using attributes)HGLRC
that we will really be using - Fix up how we acquire the pixel format when calling
wglChoosePixelFormatARB()
, by passing the attributes correctly. Also stop using theWGL_ARB_multisample
extension to reduce unneeded draws. Thanks to Benjamin Otte for pointing things out and for the patches.
With blessings, thank you!
Fixes issue #5808 (closed).
Edited by Chun-wei Fan