I have been programming along with the series and up until this point and I hadn't encountered a problem that I couldn't debug on my own, but this one has me stumped.
Basically, the wlgCreateContextAttribsARB() call in Win32CreateOpenGLContextForWorkerThread() fails, breaking the whole texture download system. Using GetLastError() returns the code for ERROR_INVALID_OPERATION, which the OpenGL docs tell me means either the HGLRC for the shared context isn't valid, or the shared context was created on a different window device context to the one passed into wglCreateContextAttribsARB(). (Also a few other things that didn't seem relevent, but
hereis the documentation in question).
I verified that the HGLRC for the shared context is valid, but strangely calling GetDC(Window) inside of Win32CreateOpenGLContextForWorkerThread() returns a different HDC that the GlobalDC. I believe this gives some indication of problem, but I cannot explain what exactly.
I have CS_OWNDC specified on the window class, which I thought was supposed to give your window a unique device context. I have also tried CS_CLASSDC to no avail. So, I am at a loss as to why different threads would return different HDCs when GetDC() is called.
Furthermore, this only seems to happen on worker threads in the high and low priority queues. Calling wlgCreateContextAttribsARB() is successful when called using the shared context on the main thread.
I tried transplanting the unaltered Handmade Hero, win32_handmade.cpp file into my codebase (as the platform layer I have written has diverged somewhat from this) however the problem persisted. More concerning is that I built the entire unaltered handmade hero codebase for day 244 and it too had the same issue. Obviously Casey doesn't have this issue in the episode.
So, that's that. I'm utterly clueless on how to proceed as this is beyond my meager knowledge of programming on windows. Clearly a problem to do with threading, but with even vanilla Handmade Hero having the same problem it suggests it is a problem with my computer specifically.
Thanks for reading, I hope my explanation was clear enough. Any thoughts?