[vtkusers] No direct rendering under Linux (X11) with SWT (Java)

Christopher Auer christopher.auer at web.de
Wed Jul 27 03:58:15 EDT 2005

Hello everyone,

we are currently developing a VTK application under Java using the
"standard widget toolkit" (SWT - also known from the eclipse project
http://www.eclipse.org). We developed our own SWT widget to display VTK
data sets. It works just like the vtkPanel and the vtkCanvas included in
the VTK package. We would also contribute the code to the community if
you are interested!

A few words to SWT: SWT uses the native GUI library of the operating
system. Under Linux (X11) this is GTK2 (should also work with Motif) and
under Windows this is MFC. SWT stores the operating system dependent
handles in members of the SWT classes. In our implementations this
handles are simply passed to the VTK RenderWindow class (SetDisplayId
and SetWindowId): The window id is the X-handle of the widget and the
display id the current X-display handle. This works very  fine with VTK:
The content of the vtkRenderWindow is displayed and the events are also
fired properly.

The only problem we have is that no direct rendering is active (the
method IsDirect returns false). This are the things we tried out to fix
the problem (obviously with no solution):

- we deactivated the stereo option in the RenderWindow
- we set "multi sampling" to 0 in the RenderWindow
- we created our own gl context using the current displa
(XOpenDisplay( NULL ) ) in the shared object library where our
JNI-RenderCreate call is located: glXIsDirect returns true with STEREO
and MULTISAMPLING disabled

At first we worked with the vtkPanel/vtkCanvas classes: To get them
running we had to use a SWT_AWT bridge class. The bridge class returns a
AWT-frame for the passed SWT-Composite (a widget container). In the
AWT-frame you can place the vtkPanel/vtkCanvas. This only partly works,
because SWT and AWT run in different dispatch threads (we always had a
lot of concurrency problems). So we decided to make our own

One thing we found out is that whether direct rendering is available or
not is decided only on the properties of the X11-display and the options
of the glXChooseVisual-call. The properties of the window/widget are not

Thanks in advance for any helping hand!

Christopher Auer
Christopher Auer <high.on.bonsai at gmx.net>
Christopher Auer <christopher.auer at web.de>

More information about the vtkusers mailing list