[vtkusers] rendering offscreen

Robert Belleman robbel at wins.uva.nl
Thu Nov 9 05:10:03 EST 2000


On Wed, Nov 08, 2000 at 11:03:17AM -0800, John Shalf wrote:
> there are several ways to go about it.  Here is a sampling (there are
> different trade-offs for each method).
[snip]

In addition to John's, I would have included another trick to do
offscreen rendering on Unix systems which can be very versatile: through
a virtual frame buffered X server (such as Xvfb(1)). Unfortunately, this
only seems to work *in part* with Vtk, which IMO is a Bad Thing. 

The trick involves starting an X server that renders to memory/disk
instead of a graphics card, (see also
http://www.sunworld.com/sunworldonline/swol-03-2000/swol-03-xvfb.html?0320a),
and then starting your application using X's "-display" (to get the
program to render on the virtual X server) and "-geometry" (to set the
size and position of the window the program should render in) options.

For example; you would create a 4096 x 4096 TrueColor snapshot of *any*
X program's output by doing something like this:

  # create a huge virtual framebuffered X server on display :9.0
  $ Xvfb :9 -screen 0 4096x4096x32 &

  # run your program, render to virtual framebuffer
  $ ./myprogram -display :9 -geometry 4096x4096 &

  # take a snapshot
  $ xwd -display :9 -root -out snapshot.xwd

Unfortunately, this convention doesn't seem to be fully endorsed with
Vtk...  Take Vtk/Tcl scripts for example; when I execute a Vtk/Tcl script
as follows, it looks like Vtk simply discards the script filename and
jumps to an interactive Tcl shell:

  $ vtk -display :9 graphics/examplesTcl/Decimate.tcl
  %

Awkwardly enough, Tk's toplevel "." window *is* opened on display :9.
Note that this is probably not really Vtk's mistake because "wish" does
exactly the same.

Luckily, there's a workaround for this deficit by specifying the display
you want to render in as an environment variable, like in the following:

  $ DISPLAY=:9 vtk Decimate.tcl &

Exactly The same goes for C++ Vtk programs; as vtkRenderer/RenderWindow
don't do any commandline argument passing themselves, you need to pass
the display you want to render on with the DISPLAY environment variable:

  # so not:
  $ ./Mace -display :9

  # but:
  $ DISPLAY=:9 ./Mace


Unfortunately there is, AFAIK, no workaround for the "-geometry" option
to scale your window to the max available resolution without changing
your code (or being smart when creating a vtkRenderWindow in *all* your
Vtk programs). So this:

  $ DISPLAY=:9 ./Mace -geometry 4096x4096

won't have any influence.

I always thought that these "common" options for X programs were one of
the greater strengths of X windows, but only if all X programs support
them correctly.  How about adding support for this in Vtk?

Best,
-- Rob

PS: Xvfb can be used to do more wonderful things, but that's a little
    beyond the scope of this subject...
    See http://carol.wins.uva.nl/~robbel/XiVE/ if you're curious.

[] Robert Belleman         X  Section Computational Science            []
[] robbel at wins.uva.nl     |X| University of Amsterdam, the Netherlands []
[] tel: (+31) 20 525 7510  X  http://www.wins.uva.nl/~robbel/          []





More information about the vtkusers mailing list