Unable to lock surface

Hi,

You may tell from another thread that I’m currently struggling with jogl and threads. Now I’m trying something but getting the “Unable to lock surface” exception.

There are no threads on this forum on this and the only explanation I found was this:

  1. net.java.games.jogl.GLException: Unable to lock surface

JOGL appears to have some very weird internal setup timing that causes problems in odd ways. This exception comes when you have attempted to do something to the GLCanvas before adding it to another component that is not already visible. To avoid this, make sure you call setVisible(true) on the containing Frame/Window before adding the GLCanvas.

This seems to occur only when I try to initialize things from the Swing thread.

Can someone tell me more about what’s going on here?

Thanks.

Pahidla

JOGL does ‘lazy initialisation’ to create
the OpenGL context: the GLContext object.

If you step thru the code in the debugger,
you will notice that GLContext is created
(‘realised’) in GLCanvas.addNotify() method.
addNotify() is a recent new method in Swing
that informs a component that it has been
added to a container. Similiarly, GLContext
is destroyed in the GLCanvas.removeNotify()
method which is called when it is removed
from its container.

So what this means for you is that you
should only make GL/GLU calls between
addNotify() and removeNotify() methods.
This is mentioned in the JOGL release notes
thread in this forum.

Lastly, you should look at Foxtrot 2.0 as a
supplement to Swing: foxtrot.sf.net
All the professional UI developers I know
use it.

.rex

Hi there :slight_smile:
I’d like to take a look to your foxtrot library but the link seems not valid :frowning:
I’d really thank you if you could give a valid one to e1 :wink:

Try this: http://foxtrot.sourceforge.net/