OpenGL with SWT

SWT is a rapidly rising alternative to AWT and Swing. It came from the
Eclipse Project, but is a very good
standalone toolkit in its own right. It does many things in a completely
different fashion and uses it's own native code interfaces, thus completely
independent of AWT. Until mid 2005 there was no capability for rendering to
SWT components using OpenGL. Since then a number of different efforts are
underway with different aims.

The Eclipse group have their own
SWT OpenGL page with a basic
summary of each of the approaches that could be used, as well as example code
snippets to show how each is used. Here we expand on those
as well as have access to our implementation of the JSR 231 API.

A lot of projects that use OpenGL also want to use OpenAL for spatialised
audio handling. Since you're here looking for SWT/Eclipse support, you may
also be interested in our Java OpenAL eclipse plugin
support too.

OpenGL Options

There are 3 basic options for interacting OpenGL with SWT widgets. These
options work, potentially with limited versions of SWT. These options are
to use the LWJGL API, the formal OpenGL
bindings provided by JSR 231
with an implementation that supports SWT (the default reference implementation
provided by Sun does not), or using the OpenGL API bindings and canvas classes
in the SWT codebase.

LWJGL

The LWJGL bindings are the oldest of all the interfaces to SWT. LWJGL is a
complex wrapper that includes OpenGL 2.0 as well as many other APIs, such as
OpenAL, input device handling and more. It operates by binding a GLContext to
whatever SWT Canvas you give it. It works with SWT 3.0 and later. LWJGL has been
used in many different gaming projects.

JOGL

The JOGL bindings are those formallised within the Sun Java Community Process.
They use the package javax.media.opengl. The formal bindings are
unfortunately, dependent on AWT. A lot of work has gone into trying to reduce
this significantly, but there are still many dependencies. There is a reference
implemetation put out by Sun that works under a limited set of circumstances.
One of the biggest problems has been the direct accessing of the native
interface to AWT under the covers. On Macs, in particularly, this can lock the
entire computer up solidly (see
Eclipse Bug ID 67384).

We also maintain a separate implementation of the JOGL APIs that do cater to
SWT directly that doesn't interact with AWT at all. These are still under heavy
development, but we're already using them as part of Aviatrix3D and Xj3D on
Win32 machines (other platforms following rapidly). You can download and read
more about these bindings on our JOGL page. You can
also find on that page an Eclipse plugin implementation of the full SWT + JOGL
implementation code.

Eclipse Native Bindings

The Eclipse project is also offering their bindings to OpenGL as well. These
are available from version 3.2M3 and later. These bindings are relatively
simple, catering only to OpenGL 1.1 (ie nothing much more than geometry and
basic textures). These can be found in the package
org.eclipse.opengl. There appears to be no interest in supporting
versions later than 1.1. The good thing is that this will be shipped by default
with Eclipse, so developing a plugin using them won't require any extra JARs.