Anyone have any luck with painting the contents of an X Pixmap into a glx context? I tried several variants of the following with no luck:
pmap = XCreatePixmap(…);
XCopyArea(… root, pmap, …);
glxpmap = glXCreateGLXPixmap(… pmap);
glXMakeCurrent(display, pmap, cx);
backdrop = malloc(width * height * 4);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, backdrop);
glXMakeCurrent(display, win, cx);
glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, backdrop);
No luck. If I just XCopyArea() to the win itself and forget all this pixmap stuff, I SOMETIMES get what I want (ie gl primitives draw on top of the copied area). But it feels like a race condition because approx. 60% of the time the primitives and even the glClear() seem to be drawn first because they are obstructed by the copied area. glXWaitX() dosen’t seem to work ( I don’t even know if it works for XCopyArea actually ).
Any ideas would be very helpful. Thanx.