Hello Guest

How to embed LWJGL in Swing/AWT Window?

  • 10 Replies
  • 31677 Views
How to embed LWJGL in Swing/AWT Window?
« on: July 29, 2010, 10:10:11 »
Hi,

Does anyone have a basic template (i.e. code) for how to embed an LWJGL display in a Swing/AWT window?
I'm creating a game and would like to embed a LWJGL display in such a canvas so I can use buttons and sliders, etc.

Also, is it possible to use Swing/AWT based sounds in conjunction with LWJGL-based OpenAL sounds?

I'm using NetBeans, btw.

Thanks for helping this little newbie!
 :D
« Last Edit: July 29, 2010, 10:12:11 by honeybadger »

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #1 on: July 29, 2010, 21:31:07 »
You can take a look at the TWL Theme editor code: http://hg.l33tlabs.org/twlthemeeditor/file/tip/src/de/matthiasmann/twlthemeeditor/Main.java it uses an AWT frame to create a resizable GL display.

But mixing AWT/Swing UI elements with OpenGL is not so nice - better to use a 100% OpenGL UI like TWL.

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #2 on: July 29, 2010, 21:41:12 »
Haha Matthias, promoting TWL wherever you can :P

But seriously, honeybadger, TWL is seriously awesome. :)

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #3 on: July 30, 2010, 10:42:11 »
Thanks Matthias! I checked out TWL... looked impressive. I'll definitely give it go some time (when I'm a bit better more experienced).

Right now I'm just looking for a pure LWJGL + AWT/Swing implementation. Would you by any chance have such a template?

PS: I tried downloading the "Main.java" link you posted, but I couldn't get it to work on Netbeans as it came up as an HTML file?
Any hints on how I can try out the code quickly on Netbeans? Cheers!

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #4 on: July 30, 2010, 11:51:27 »
Have you tried the AWT Gears demo so far?

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #5 on: July 30, 2010, 12:06:12 »
What's AWT Gears? Is that the one using JOGL? Do you have the URL?

Would prefer one with LWJGL though.

Cheers!  ;)
« Last Edit: July 30, 2010, 12:11:35 by honeybadger »

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #6 on: July 30, 2010, 16:49:32 »
Just in the regular lwjgl archive. Inside the test package you will fonde some awt tests. For the java source you may download the lwjgl source package which contains all the code you will need.

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #7 on: July 30, 2010, 16:59:59 »
Right now I'm just looking for a pure LWJGL + AWT/Swing implementation. Would you by any chance have such a template?

PS: I tried downloading the "Main.java" link you posted, but I couldn't get it to work on Netbeans as it came up as an HTML file?
Any hints on how I can try out the code quickly on Netbeans? Cheers!
I linked you a Java source which uses Display.setParent() to get a OpenGL context in a AWT Frame. If this is not enough example for you then you are out of luck.
As this source is stored in Mercurial you can either use the "raw" link, or just clone the complete repository. But you won't be able to compile/run that class alone.

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #8 on: August 03, 2010, 15:31:56 »
Thanks for the link, Matthias. I'll spend some time to go thru your code and try to understand it. I'm new to LWJGL, as you can see  ;)

Cheers for your time and patience! Greatly apppreciate it!

*

Offline Krux

  • *
  • 24
Re: How to embed LWJGL in Swing/AWT Window?
« Reply #9 on: May 23, 2012, 23:13:42 »
lets revive this topic. I've seen the AWT classes, and they are cool, but is it also possible to use swing, and not AWT?

Re: How to embed LWJGL in Swing/AWT Window?
« Reply #10 on: May 24, 2012, 13:00:16 »
...is it also possible to use swing, and not AWT?
Yes and no. Yes you can use LWJGL in Swing, but since Swing uses light-weight components, the LWJGL view will appear on top of any Swing components (like a menu that drops down over top of a LWJGL view will not show up).
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D