aboutsummaryrefslogtreecommitdiffstats
path: root/progs/wgl
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-06-17 14:48:25 +0100
committerJosé Fonseca <[email protected]>2009-06-17 15:23:25 +0100
commit557421b6de9d8cba7e71828ec3a60a344fff9e88 (patch)
tree809cb9f4c71a13dac58c64392f9a57eb4ad085e8 /progs/wgl
parent25f0c33bb3509958a532bdd72b3945c1d5d1cad5 (diff)
progs/wgl: Get wglShareLists working in wglthreads.
wglShareLists is a little picky -- it seems to check if it has exclusive access to a lock, and fails if it doesn't. This allows the texture to be shared with all windows.
Diffstat (limited to 'progs/wgl')
-rw-r--r--progs/wgl/wglthreads/wglthreads.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/progs/wgl/wglthreads/wglthreads.c b/progs/wgl/wglthreads/wglthreads.c
index 2f67dd670f2..405b5db8842 100644
--- a/progs/wgl/wglthreads/wglthreads.c
+++ b/progs/wgl/wglthreads/wglthreads.c
@@ -331,7 +331,9 @@ draw_loop(struct winthread *wt)
if (Locking)
EnterCriticalSection(&Mutex);
+
SwapBuffers(wt->hDC);
+
if (Locking)
LeaveCriticalSection(&Mutex);
@@ -481,7 +483,8 @@ create_window(struct winthread *wt, HGLRC shareCtx)
}
if (shareCtx) {
- wglShareLists(shareCtx, ctx);
+ if(!wglShareLists(shareCtx, ctx))
+ Error("Couldn't share WGL context lists");
}
/* save the info for this window/context */
@@ -504,10 +507,22 @@ ThreadProc(void *p)
struct winthread *wt = (struct winthread *) p;
HGLRC share;
+ /* Wait for first thread context */
+ if(Texture && wt->Index > 0) {
+ WaitForSingleObject(WinThreads[0].hEventInitialised, INFINITE);
+ share = WinThreads[0].Context;
+ }
+ else
+ share = 0;
+
share = (Texture && wt->Index > 0) ? WinThreads[0].Context : 0;
create_window(wt, share);
SetEvent(wt->hEventInitialised);
+ /* Wait for all threads to initialize otherwise wglShareLists will fail */
+ if(wt->Index < NumWinThreads - 1)
+ WaitForSingleObject(WinThreads[NumWinThreads - 1].hEventInitialised, INFINITE);
+
draw_loop(wt);
return 0;
}
@@ -591,13 +606,17 @@ main(int argc, char *argv[])
printf("wglthreads: creating threads\n");
- /* Create the threads */
+ /* Create the events */
for (i = 0; i < NumWinThreads; i++) {
- DWORD id;
-
WinThreads[i].Index = i;
WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL);
+ }
+
+ /* Create the threads */
+ for (i = 0; i < NumWinThreads; i++) {
+ DWORD id;
+
WinThreads[i].Thread = CreateThread(NULL,
0,
ThreadProc,
@@ -606,8 +625,6 @@ main(int argc, char *argv[])
&id);
printf("wglthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
- WaitForSingleObject(WinThreads[i].hEventInitialised, INFINITE);
-
threads[i] = WinThreads[i].Thread;
}