Simple way to convert lwjgl app to using swing

Started by BatKid, November 12, 2007, 19:00:44

Previous topic - Next topic

BatKid

Hi all,

I am the author of an educational 3d engine (env3d.sourceforge.net).  It is using lwjgl's Display class for the main game window. 

My question is, is there a simple way to convert this to use swing?  I know that I could use the AWTGLCanvas (sp?) for display, but it seems like the two approaches are not very compatible and converting between them would require a major change in code structure.  Am I correct in this case?  I hope I am wrong because I would like to do minimal work on this ;)

Thanks
Projects: 
   Env3D (http://env3d.org): Learn Java in 3D
   WhaleChat (http://whalechat.com): A 3D social programming experiment

Matzon

afaik, the AWTGLCanvas works fine, barring any heavyweight issues.
if you absolutely must use swing only components, then JOGL is probably the way to go

princec

Kev Glass recently showed me a demo of Swing rendered into a LWJGL window at 60fps - basically Swing was being active rendered into a texture and then the whole thing was blitted every frame and it worked fantastically well, with ClearType fonts and everything. All the event handling was trapped and sent to Swing too. I was seriously impressed. Hopefully he will tidy it up and release the hackery as a library that Just Works.

Cas :)

Evil-Devil

Using the AWTGLCanvas in a Swing only application is no problem. Just make sure that every component that have to be rendered on top of the glcanvas is set heavyweight.

kevglass

This stuff uses the same ideas as JMEDesktop (and Xith3D, and Yazel before that). Swing is added to an invisible frame and then rendered into a buffered image. This is then updated into the texture which can then be rendered across the screen.

I've recoded this from scratch but it certainly owes so kudos to JMEDesktop, which was used as reference. This time the AWT event interaction has been simplified, as has dirty rectangle tracking. Also performance was improved by using an texture format equivalent to the BufferedImage underlying storage - this makes grabbing the contents of the buffered image faster.

In short, here's that thing Cas was talking about, it renders Swing ... to LWJGL:

http://www.cokeandcode.com/Swingle/swingle141107.zip

Kev

Fool Running

QuoteIn short, here's that thing Cas was talking about, it renders Swing ... to LWJGL:
I'm definitely going to look at that. 8)
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D