GLException: Surface already unlocked

i have my app running under mac os x. now we tried it on windows. here’s the exception:


net.java.games.jogl.GLException: Surface already unlocked
        at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.unlockSurfa
ce(WindowsOnscreenGLContext.java:192)
        at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.free(Window
sOnscreenGLContext.java:134)
        at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:271)
        at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:194)
        at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)
        at net.xytanics.games.engine.Viewport.draw(Viewport.java:191)
        at net.xytanics.games.smsrace.Controller$TickTimerTask.run(Controller.ja
va:88)
        at java.util.TimerThread.mainLoop(Unknown Source)
        at java.util.TimerThread.run(Unknown Source)

the difference i see in the init() method is this:
mac: net.java.games.jogl.GLCanvas[canvas0,0,22,800x578]
win: net.java.games.jogl.GLCanvas[canvas0,4,23,792x573,invalid]

the ‘invalid’ looks really bad there. any idea, what i have to do to the canvas to make it valid?
here’s my construction:


            Frame frame = new Frame("Viewport Frame");
            DisplayMode bMode = aDevice.getDisplayMode();
            frame.setBounds((int) (bMode.getWidth() - bounds.size.width) >> 1, (int) (bMode.getHeight() - bounds.size.height) >> 1, (int) bounds.size.width, (int) bounds.size.height);
            GLCapabilities capabilities = new GLCapabilities();
            canvas = GLDrawableFactory.getFactory().createGLCanvas(capabilities);
            canvas.addGLEventListener(this);
            frame.add(canvas);
            frame.show();

do i have to add frame.setVisible(true) or something like it?

This is a known problem. You’ve added the listener to the canvas before it is added to a window and the window has been made visible. I really don’t know why there is such a heavy order of operations problem with JOGL. To get the window to show up without exceptions, you need the following order:

Create Frame
Create Canvas
Add Canvas to frame
Show frame
Add listener(s)
Set user-control render thread.

Does anyone have a small, self-contained example that illustrates this problem? If so, please file an issue on the JOGL web page and attach it…we can’t (easily) fix bugs that we can’t reproduce…

Here is an example app that regularly fails. 379 lines is too long to post, so you can find it at Order.java

As I stated in another thread, this app does not fail with 1.1b04 (July 16) on this card. Backing up to 1.1b04 (July 2), I regularly have problems. However, I also noticed that the Microsoft driver is being selected, which may be the root of the problem.

I’ve placed comments around my two calls to frame.getContentPane().add(glCanvas, BorderLayout.CENTER);

I’m sorry to report that on a ATI Radeon Mobility 9600, order is still completely dependent. With the above source and 1.1b04 (July 16), on entering fullscreen I receive the White Screen of Death. No output is written to stderr or stdout.

Issue #100 has been submitted for this.