tags:

views:

25

answers:

1

I am trying to make a screenshot of a not visible window under X.

My first attempt was to capture the window using xwd or import (from ImageMagick). Unfortunately when window is under some other windows the hidden parts are black. What's even worse is that when window is not on the current desktop I get a BadMatch error.

The next thought was to use Xnest which would create a new X instance just for this one application and it would be always on top. And I run across other problem. Xnest does not support OpenGL.

Some searching on google and I find [Xephyr][1] which does support OpenGL... but not hardware accelerated so it's not accaptable as it kills my CPU.

The same goes for Xvfb which also uses CPU to render OpenGL. Below is part of the output from the glxinfo:

OpenGL vendor string: Mesa Project
OpenGL renderer string: Software Rasterizer
OpenGL version string: 2.1 Mesa 7.8.2
OpenGL shading language version string: 1.20

The only thing left that I can think of is to somehow use Xlib to force my X server to render window to a pixbuf. Unfortunately I have almost no knowledge of Xlib.

So my question is how can I get a screenshot from a not visible window of a application which uses OpenGL under X?

As for now I am only able to make a screenshot using [Python-Xlib][2] and PIL. Also any other solution using Python or C is acceptable.

A: 

This is not possible as far as I know. The issue is that the pixels you're trying to save literally don't exist. The X server and the video driver are going to avoid rendering stuff that isn't visible anyhow.

If you can control the GL app there are probably things you could do in GL, as Matias mentions. e.g. framebuffer objects extension lets you render to offscreen textures.

Havoc P