[vtkusers] Offscreen-rendering under VTK with C++/TCL/Java

Bill Hill bill at hgu.mrc.ac.uk
Wed May 12 05:08:18 EDT 2004


I've been involved in setting up a prototype grid service which
uses VTK for volume rendering. This system runs under Linux and
uses VTK from Java. I couldn't get the off-screen rendering to
build using mangled mesa for the java binding either (see post
of 2004-02-03). My work around was to make a separate build of
VTK (version 4.2.2) using mesa and then render into X11 virtual
frame buffers. I'm using Mandrake Linux where the virtual
frame buffer RPM is Free86-Xvfb but equivalents probably exist
for other distributions. I also use this for creating movies
off-line, without locking up a screen. Unfortunately you
can't get any acceleration for 3D rendering using this method
under Linux, although I think this is possible with an SGI
and IRIX.

Once you've got this built and installed you should be able
to run C++/tcl/java apps using a virtual frame buffer. Steps
(using tcsh or csh, translate for sh or bash) are:

Create a magic cookie, create an authentication file and
then start an X11 virtual frame buffer (Xvfb) using the
authentication file.

set MCOOKIE=`mcookie`
setenv XAUTHFILE  `pwd`/Xauthority
xauth add :2 0 "$MCOOKIE"
Xvfb :2 -screen 0 1280x1024x24 -shmem &

In this case the display number is :2, the screen is 1280x1024
pixels with a depth of 24 bits and the virtual frame buffer is
run using shared memory. Once the virtual frame buffer is running
a VTK application can use it as in the following example where
the application is app.

setenv DISPLAY :2
setenv XAUTHORITY "$XAUTHFILE"
java app

Watch out that changing the XAUTHORITY and DISPLAY environment
variables will leave the shell unable use it's previously
configured display.

This isn't the best solution, that would be off-screen
rendering working for the Java binding, but it does work.

Have fun,
Bill



More information about the vtkusers mailing list