Skip to content

wgl: do not set up window-hook per thread

Erik Faye-Lund requested to merge d3d12-fix_wgl_crash into msclc-d3d12

Instead of setting up the window-hook per thread, we can pass in a thread-id of zero here, which applies to all threads. This works fine, because we don't really do anything else thread-specific in the window-hook.

This let's us simplify things a lot. This makes the whole dance around what threads has been initialized and and which hasn't entirely moot, so let's also remove that.

The end result is straight-forward code that initializes and deinitializes once, as the DLL is loaded and unloaded.

This has the added benefit of fixing a bug that is tricky to fix otherwise; we don't actually deinitialize all threads in the case where opengl32.dll gets unloaded before the application exits. This means we leave a window-hook to unloaded code active, which crashes hard. Without this patch, Quake 3 Arena crashes on exit, for example.

Merge request reports