Skip to content

Few fixes for WGL after recent updates

Chun-wei Fan requested to merge fix-wgl into main

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 call wglDeleteContext(), 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 dummy HGLRC, before we setup the "real" dummy HGLRC/HDC that we use to emulate surfaceless contexts. The reasoning is because we must use CS_OWNDC for creating HWND/HDCs for GL usage, meaning that GetDC() calls from the same HWND will always return us the exact same HDC even if DeleteDC() was called on the HDC, where SetPixelFormat() can only be called once on that HDC. This will also ensure the "real" dummy HGLRC/HDC use the correct pixel format as ChoosePixelFormat() and wglChoosePixelFormatARB() can return different pixel formats as wglCoosePixelFormatARB() 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 the WGL_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

Merge request reports