Hi people. I just downloaded jogl and I’m starting to learn about it. I’m browsing the demos but I coudln’t find any about using jogl in a swing form. Where can I find that? Just something very simple with one button.
Are these few demos all I can find about jogl?
The Gears demo is about as good a starting point as you’ll get, using Swing in conjunction is pretty simple - you’ll just need to add your GL canvas into a JFrame or whatever parent control you want.
You’ll run into the usual lightweight vs. heavyweight issues, but you can usually find a suitable way to work around these unless you’re doing something really exotic.
What’ are those lightweight vs. heavyweight issues? I want to use jogl for a physics simulation so performance would be my main objective. Are you talking about that?
See here: http://www.j3d.org/tutorials/quick_fix/swing.html
In short, if you have a lightweight widget like a Swing button and a heavyweight widget like a GL canvas which overlap, regardless of actual z ordering the heavyweight canvas will be drawn on top.
I’ve not had any problems so far, usually the only overlapping that causes problems is the pop up menus, which can be fixed with the ‘force heavyweight’ option.
http://java.sun.com/products/jfc/tsc/articles/mixing/
But on that note, isn’t there a GLJPanel just for such occassions?
Someone on the Jogl team mentioned that the GLJPanel doesn’t have any hardware acceleration, so for most people i’m guessing it’ll be a last resort. There was a thread about it lying around here somewhere, I doubt that acceleration is trivial to implement for the GLJPanel…
Edit: Found it - http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1060458437
Great, thanks a lot
The only instance where you’ll run into serious issues is with JInternal frame and JDesktop. Other than that, there aren’t many opportunities for your Canvas based component to run slow.
There are only a couple things wrong with GLJPanel in its current form. Right now the default capabilities chooser spits out incompatible pixel formats for offscreen rendering. I will make a full post tomorrow and hopefully on monday or tuesday you can grab a nightly build and start using GLJPanel. It is painfully slow though.