Creating a GLCanvas from the AWT thread

Hi,

I have a problem (and some workaround) when creating a GLCanvas from the AWT thread: I open a JFrame with a JButton inside that, when pressed, triggers the creation of a GLCanvas that is added to the frame’s content pane.
When the creation of the GLCanvas triggers a reshape (I call setSize), I get the following exception:

net.java.games.jogl.GLException: Unable to lock surface
(stack trace at end).

A workaround that I found is to create a new thread in the actionPerformed of the button-listener (AWT thread) and
create the GLCanvas in the new thread. The button
code is as follows:


JButton button = new JButton( "Activate Gears" );
button.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e ) {
          Thread init_3d_thread = new Thread() {
            public void run() {
               // create GLCanvas
              startGears( pane );
            }
          };

          init_3d_thread.start();

          try {
            init_3d_thread.join();
          } catch ( InterruptedException ex ) {
            ex.printStackTrace();
          }

The AWT thread just waits until the creation of the GLCanvas finishes (in startGears), but it works.
Anybody know what is going wrong (or what I am doing wrong) and why the workaround works?

I’m running under windows. I’ve got a modified gears demo that demonstrates the problem if needed.

Thanks,

Frank.

PS. Stack trace:


net.java.games.jogl.GLException: Unable to lock surface
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.lockSurface(WindowsOnscreenGLContext.java:155)
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:107)
      at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:199)
      at net.java.games.jogl.GLCanvas.reshape(GLCanvas.java:105)
      at java.awt.Component.setBounds(Component.java:1664)
      at java.awt.Component.resize(Component.java:1601)
      at java.awt.Component.setSize(Component.java:1593)
      at Gears.startGears(Gears.java:93)
      at Gears$1.actionPerformed(Gears.java:61)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
...

It’s probably a bug either in JOGL or at a deeper level in e.g. the JAWT that we’ll need to work around. Could you please file an issue on the main JOGL page and provide a test case as an attachment? Thanks.