Opening LWJGL window from a SWT app on Mac

Started by mot, March 05, 2010, 01:51:16

Previous topic - Next topic

mot

..doesn't work. I get this error:

2010-03-05 02:28:25.315 java[1315:a07] [Java CocoaComponent compatibility mode]: Enabled
2010-03-05 02:28:25.316 java[1315:a07] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
2010-03-05 02:28:25.317 java[1315:a07] Apple AWT Startup Exception : _createMenuRef called with existing principal MenuRef already associated with menu
2010-03-05 02:28:25.318 java[1315:a07] Apple AWT Restarting Native Event Thread


The SWT window closes and then the app hangs, with no windows open.

It's a fairly minimal SWT app with a few buttons, one of them supposed to open a LWJGL window (org.lwjgl.opengl.Display). The button sets a static variable in the app to tell it what to do next after the SWT window is closed (so the LWJGL window is NOT being opened from a SWT callback directly) and then closes the SWT window (via shell.close, shell.dispose, display.close, display.dispose, whatever, tried different combinations, don't know the correct way).

It looks like the SWT app doesn't shut down cleanly and leaves it's menu entries associated with it, which prevents the LWJGL window from opening.

Does anyone know what could be done to make this work?

Snow Leopard, Java 1.6 32 bit, swt-3.5-cocoa-macosx, LWJGL 2.3
Tom Andrle - Catnap Games - http://www.catnapgames.com

Matthias

Why do you need an SWT frame before you create your LWJGL Display ? I assume you use it to setup some OpenGL parameters?

take a look at the TWL Demo - it uses a OpenGL display in windowed mode to select the parameters.

Ciao Matthias

mot

Yes it's a preferences and "activate full version" screen basically.

I would like to keep it as a SWT dialog. The native controls of SWT are nice and it already works fine on Windows. I believe this menu problem on Mac is just the result of my ignorance and can be solved, I just need to find out how.
Tom Andrle - Catnap Games - http://www.catnapgames.com

princec

Possibly just making life hard for yourself :/ Just use Swing and set the L&F to native which should get you a reasonably accurate Mac OS native looking GUI.

Cas :)

elias4444

(inside joke) ...slowly creeps into the conversation... looking around to make sure no one is about to pounce on him if he's wrong... (/inside joke)

I had some issues trying to do the same thing you are. I ended up using a JFrame (swing) instead. I use the native L&F if on Mac, and Nautilus otherwise (it just looks better than Linux or Windows native IMHO).

I still had some problems though, mainly with the JFrame snatching the keyboard input away from my Display context (even after the JFrame was closed and destroyed). My solution was to put the main app (that creates and displays the JFrame) into a Thread.sleep() loop until the JFrame was detected as no longer visible. For some reason, this allows the main app to retain keyboard input with the Display that I create later.

I've run into similar Keyboard dueling with the Display.setParent() technique for embedding your Display into Swing. The solution there was to run the Display loop in a separate thread.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com