I am new to X and OpenGL. I have a program made by someone else. It draws what I want. Now I need to save the resulting picture to a file, in whatever format (say xwd would do as it can be converted to any other).

The question seemed very straightforward, still I found no clues in manuals. The best approximation I found so far: system call of xwd with -id option - seems to work in principle but not satisfactory in practice as it dumps the window as it appears on screen, i.e. with whatever rubbish happened to be above it at the time of call etc.

Can anyone give a sensible advice? Thanks in advance

I work on linux, write in C

- Vadim