From 2c59a9ebf768c77aeca78984dab6e1726d979dc2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 19 Nov 2021 20:56:44 +1100 Subject: [PATCH] OpenGL: Attempt to fix rare crashing on Windows for GPU drivers that return NULL from wglGetProcAddress for core OpenGL functions --- src/Window_Win.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Window_Win.c b/src/Window_Win.c index 35c71a538..f9251e103 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -652,7 +652,14 @@ void GLContext_Free(void) { } void* GLContext_GetAddress(const char* function) { + static const cc_string glPath = String_FromConst("OPENGL32.dll"); + static void* lib; void* addr = (void*)wglGetProcAddress(function); + if (!GLContext_IsInvalidAddress(addr)) return addr; + + /* Some drivers return NULL from wglGetProcAddress for core OpenGL functions */ + if (!lib) lib = DynamicLib_Load2(&glPath); + addr = DynamicLib_Get2(lib, function); return GLContext_IsInvalidAddress(addr) ? NULL : addr; }