Using a GLCanvas with SWT ?

Has anyone tried to mix SWT with a JOGL GLCanvas ? Does it work and does it solve the classic swing overlay problem.

Any performance or stability problems ?

// Tomas

Hi, I experimented with JOGL and SWT quite extensively about a year ago. I can post you the details later on today (I’m in a hurry atm).

Cheers

To use GLCanvas with swt, I do this:

  • First I extend a Panel and add a GLCanvas:

public class GLPanel extends Panel{
private GLCanvas canvas = null;
private GL gl;
private GLU glu;

public GLPanel(){
  GLCapabilities cap = new GLCapabilities();
  this.canvas = GLDrawableFactory.getFactory().createGLCanvas(cap);
  this.setLayout(new BorderLayout());
  this.add(canvas);
  }

  .....

}

  • Then I add the GLCanvas to a SWT Composite, with SWT_AWT bridje.

private void addGlCanvas(Composite parent)
{
FillLayout fl = new FillLayout();
parent.setLayout(fl);
Composite glCompo = new Composite(parent, SWT.EMBEDDED);
// bridje swt -> awt
fDrawSurface = new GLPanel();
fDrawSurface.addAdjustmentListener(this);

  Frame awtFrame = SWT_AWT.new_Frame(glCompo);
  awtFrame.add(fDrawSurface);
  }

Work’s fine.

thx :slight_smile:

BTW. Did you expirience any overlay problems ? Like the traditionaly menus appearing appearing behind the canvas and such.

// Tomas