LWJGL
May 20, 2013, 14:50:34 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: How to embed LWJGL in Swing/AWT Window?  (Read 6466 times)
honeybadger
Newbie
*
Posts: 7


« on: July 29, 2010, 03: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!
 Cheesy
Logged
Matthias
Talks Too Much
***
Posts: 180


WWW
« Reply #1 on: July 29, 2010, 14: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.
Logged

quasar
Newbie
*
Posts: 1


« Reply #2 on: July 29, 2010, 14:41:12 »

Haha Matthias, promoting TWL wherever you can Tongue

But seriously, honeybadger, TWL is seriously awesome. Smiley
Logged
honeybadger
Newbie
*
Posts: 7


« Reply #3 on: July 30, 2010, 03: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!
Logged
Evil-Devil
Prolific Timewaster
****
Posts: 298



WWW
« Reply #4 on: July 30, 2010, 04:51:27 »

Have you tried the AWT Gears demo so far?
Logged
honeybadger
Newbie
*
Posts: 7


« Reply #5 on: July 30, 2010, 05:06:12 »

What's AWT Gears? Is that the one using JOGL? Do you have the URL?

Would prefer one with LWJGL though.

Cheers!  Wink
Logged
Evil-Devil
Prolific Timewaster
****
Posts: 298



WWW
« Reply #6 on: July 30, 2010, 09: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.
Logged
Matthias
Talks Too Much
***
Posts: 180


WWW
« Reply #7 on: July 30, 2010, 09: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.
Logged

honeybadger
Newbie
*
Posts: 7


« Reply #8 on: August 03, 2010, 08: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  Wink

Cheers for your time and patience! Greatly apppreciate it!
Logged
Krux
Newbie
*
Posts: 22


« Reply #9 on: May 23, 2012, 16: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?
Logged
Fool Running
Nerdus Imperius
*****
Posts: 742


« Reply #10 on: May 24, 2012, 06: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).
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!