I'm trying to create a multi-threaded program where all of the rendering is done on the primary thread while the message handling (and window creation) is done on a secondary thread. The following line of code SwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (void**)&back_buffer); in the initialization function produces an access violation error (0xc0000005) when the initialization function is placed on the main thread.
How can I fix this error without placing the initialization function on the secondary thread?
EDIT: I have posted all of the relevant code here.
On line 49 of Application.cpp,
while (HWindow != nullptr);was waiting forHWindowto becomenullptr. But HWindow is initialized asnullptrand therefore the while loop would skip and try to initialize a window that hasn't been created yet.That line now reads
while (HWindow == nullptr);. This means the loop runs until the window has been created, thereby blocking initialization of a window that doesn't exist.