PDA

View Full Version : GLX data Copying



Tan_has
02-05-2013, 05:23 AM
I am very new to GLX, i have created a xwindow as a drawable, i have a glxpixmap, i need to copy a bytearray data to this pixmap.
Is there any mechanism by which i can do this.

_jesse_
02-06-2013, 09:39 AM
Can you show some code ?

Dark Photon
02-06-2013, 03:02 PM
Have you looked at XCopyArea?

Also, if you don't need the window, you can create your GLXContext to target the pixmap directly.

Tan_has
02-07-2013, 04:47 AM
Thanks!!!
I looked at XCopyArea, it says both drawables to be of same root window, my drawable is window.
I did one thing now by creating a XcreatepixmapfromBitmap, then copying, but it looks it would be very costly. My code architecture is such that i can use window only as drawable. So looking out for some thing which can directly copy the data into this window.

Dark Photon
02-07-2013, 05:24 AM
I dug up a Green Book ("OpenGL Programming for the X Window System") and it describes rendering into XPixmaps (not what you want exactly, but potentially useful).

Basically, glXCreateContext, XCreatePixmap to create an XPixmap, pass that to glXCreateGLXPixmap to create a GLXPixmap wrapper around the XPixmap, and then glXMakeCurrent on the GLXPixmap to make it active for rendering.

You might be able to use this to copy window data off to a PBO or somewhere, switch to the GLXPixmap, and then copy the data back to it. Or possibly copy between contexts with sharing enabled.

Here's the paraphrased code snippets:


cx = glXCreateContext( dpy, vi, NULL, False );
if ( !cx )
ouch;
pmap = XCreatePixmap( dpy, RootWindow( dpy, vi->screen ), imageWidth, imageHeight, vi->depth );
glxpmap = GLXCreateGLXPixmap( dpy, vi, pmap );
glXMakeCurrent( dpy, glxpmap, cx );

Tan_has
02-16-2013, 12:02 PM
Thanks!!!...
i am trying by making making current context to GLX ,at that time my process is giving a segmentation fault.
I also tried by creating a ximage and then putting that image into the pixmap and then doing a xcopy to the window, but my xcopy is giving a bad request.

Tan_has
02-18-2013, 06:21 AM
Any Idea when XCopyArea generates bad request ?

The Little Body
02-18-2013, 06:50 PM
Are you certain than the pmap and glxpmap returned values are valids ?
(the requested vi->depth can for example not to be handled by the XCreatePixmap and/or GLXCreateGLXPixmap funcs)
[I doubt that this can be this but in case of ...]

Tan_has
02-19-2013, 05:59 AM
Yes it looks to me that pmap generated is fine, is there any way to cross check that ?

The Little Body
02-19-2013, 01:02 PM
Where is your XCopyArea ?

Can you give a little more code ?
(something such as http://www-h.eng.cam.ac.uk/help/tpl/graphics/X/X11R5/node25.html for example)