diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-06-17 15:22:47 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2009-06-17 15:23:25 +0100 |
commit | 1bee650ef3fd167b560986b14b3780ab07741da2 (patch) | |
tree | 793a39df0ee1cd91d97906ce58846e68b08ce682 /progs/wgl | |
parent | 6e24fdeae5038b63b6b0f94b05d4529a5f62d6ae (diff) |
progs/wgl: Fix shreadtex_mt too.
Diffstat (limited to 'progs/wgl')
-rw-r--r-- | progs/wgl/sharedtex_mt/sharedtex_mt.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/progs/wgl/sharedtex_mt/sharedtex_mt.c b/progs/wgl/sharedtex_mt/sharedtex_mt.c index 010eb873b8..779e15001d 100644 --- a/progs/wgl/sharedtex_mt/sharedtex_mt.c +++ b/progs/wgl/sharedtex_mt/sharedtex_mt.c @@ -50,6 +50,7 @@ struct window { float Angle; int Id; HGLRC sharedContext; + HANDLE hEventInitialised; }; @@ -414,6 +415,10 @@ threadRunner (void *arg) Error("Couldn't obtain HDC"); } + /* Wait for the previous thread */ + if(tia->id > 0) + WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE); + pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; @@ -434,9 +439,16 @@ threadRunner (void *arg) } if (win->sharedContext) { - wglShareLists(win->sharedContext, win->Context); + if(!wglShareLists(win->sharedContext, win->Context)) + Error("Couldn't share WGL context lists"); } + SetEvent(win->hEventInitialised); + + /* Wait for all threads to initialize otherwise wglShareLists will fail */ + if(tia->id < NumWindows - 1) + WaitForSingleObject(Windows[NumWindows - 1].hEventInitialised, INFINITE); + SendMessage(win->Win, WM_SIZE, 0, 0); while (1) { @@ -511,20 +523,26 @@ main(int argc, char *argv[]) h[2] = AddWindow( 10, 350, gCtx); h[3] = AddWindow(330, 350, gCtx); - if (!wglMakeCurrent(gHDC, gCtx)) { - Error("wglMakeCurrent failed for init thread."); - return -1; + for (i = 0; i < NumWindows; i++) { + Windows[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL); } - InitGLstuff(); - for (i = 0; i < NumWindows; i++) { DWORD id; tia[i].id = i; threads[i] = CreateThread(NULL, 0, threadRunner, &tia[i], 0, &id); + + WaitForSingleObject(Windows[i].hEventInitialised, INFINITE); + } + + if (!wglMakeCurrent(gHDC, gCtx)) { + Error("wglMakeCurrent failed for init thread."); + return -1; } + InitGLstuff(); + while (1) { MSG msg; |