Efficient Screen Capture

Tomas Carnecky tom at dbservice.com
Fri Dec 22 02:02:25 PST 2006


jason cipriani wrote:
> How do I capture the contents of the screen in less than 10 seconds?
> 
> The following code is entirely too inefficient to be useful:
> 
> Display *disp = XOpenDisplay(NULL);
> Window win = XRootWindow(disp, XDefaultScreen(disp));
> XImage *image = XGetImage(disp, win, 0, 0, WIDTH, HEIGHT, ~0, XYPixmap);
> 
> I'm willing to hack it pretty far so any ideas (such as direct copies
> from video memory) would be useful. I am not willing to use any
> hardware other than this machine.
> 

When trying to write 'Fraps for Linux' (eg. screen capturing application 
that would be fast enough to capture (OpenGL-)games), I came across 
this: If you create a fullscreen OpenGL window, minimize it and 
glReadPixels() from the frontbuffer (glReadBuffer(GL_FRONT)), you 
effectively capture what's on the screen (that was with my binary nvidia 
driver, don't know how other drivers behave, and also, it was a long 
time ago, I think with xorg 6.9)
However, when running another OpenGL application at the same time (for 
me it was the actual game) then glReadPixels() became _very_ slow, but 
capturing normal desktop application should be ok.

tom



More information about the xorg mailing list