xeglthreads: Check current context for EGL per-thread support.
authorChia-I Wu <olvaffe@gmail.com>
Fri, 17 Jul 2009 04:21:59 +0000 (21:21 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 17 Jul 2009 17:56:32 +0000 (11:56 -0600)
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
progs/egl/xeglthreads.c

index 5cc856ab3f3ed04a2a04206b111dfb64ba6cfcc2..508dbc09432da8db51a4cf2072f5eed7e35a566e 100644 (file)
@@ -261,6 +261,12 @@ draw_loop(struct winthread *wt)
       if (Locking)
          pthread_mutex_unlock(&Mutex);
 
+      eglBindAPI(EGL_OPENGL_API);
+      if (eglGetCurrentContext() != wt->Context) {
+         printf("xeglthreads: current context %p != %p\n",
+               eglGetCurrentContext(), wt->Context);
+      }
+
       glEnable(GL_DEPTH_TEST);
 
       if (wt->NewSize) {
@@ -308,6 +314,7 @@ draw_loop(struct winthread *wt)
       }
       wt->Angle += 1.0;
    }
+   eglMakeCurrent(wt->Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 }
 
 
@@ -574,7 +581,7 @@ clean_up(void)
    }
 
    for (i = 0; i < NumWinThreads; i++) {
-      eglDestroyContext(WinThreads[i].Dpy, WinThreads[i].Context);
+      eglDestroyContext(WinThreads[i].Display, WinThreads[i].Context);
       XDestroyWindow(WinThreads[i].Dpy, WinThreads[i].Win);
    }
 }
@@ -742,7 +749,7 @@ main(int argc, char *argv[])
       }
    }
    else {
-      eglTerminate(dpy);
+      eglTerminate(egl_dpy);
       XCloseDisplay(dpy);
    }