// the display function of main thread
void display()
{
if (!loadingDone)
{
threadInit();
// display the loading stuff
}
else
{
// draw some else stuff
}
}
// thread init function
void JobQueue::start()
{
if (!started)
{
// remember display and render context for the main thread
started = true;
hMainDC = wglGetCurrentDC();
hMainRC = wglGetCurrentContext();
// (...) - create the thread
}
}
// thread function
DWORD WINAPI ThreadFunction (LPVOID lpParam)
{
// create render context based on main window's device context
HGLRC hRC = wglCreateContext(queue->hMainDC);
wglMakeCurrent(queue->hMainDC, hRC);
wglShareLists(queue->hMainRC,hRC);
// (...) - execute all jobs
loadingDone = true;
return 1;
}