After that example code uses LoadLibrary to load up OpenGL and initialize a bunch of API function pointers, it calls FreeLibrary because it doesn’t need the library handle anymore. But wouldn’t that close the entire library and invalidate all those function pointers? I guess if OpenGL is itself loaded into shared memory, a different process keeps it open, and Windows doesn’t invalidate the address space in the application, it could still work? But if that was happening, I’m not sure why OpenGL would just nondeterministically not work, I think it would crash.
So I’m confused about that. I didn’t read the source code listing super closely so I might have overlooked something obvious. But I can’t help but wonder if you’re using example code that itself is unreliable in some way. I wonder what else that code listing is dropping before it’s actually done with it…
What version of Windows are you using? What CPU is it running on?