Swing and JOGL

for a project I’m working on, I need to integrate JOGL with the framework of the project that’s already been developed. If I create a GLJPanel, I can do everything I need to and life seems good. Except for one thing: speed! My computer, with just drawing a black background, gets 26fps max just throwing out blank display() calls. If I change that GLJPanel to a GLCanvas, whammo I’m over 1000fps. However, if I use the GLCanvas, the JMenu that goes across the top gets messed up because when I click on an item, the drop down box gets drawn over by the GLCanvas and I can’t click on the items.

Weston helped explain to me that Canvas is heavyweight and swing components are lightweight and that’s where my problem lies, so I wonder, do I have any options with Swing components in JOGL where I can have an accelerated component to use? I can’t get away from the Swing components everywhere in the background. My job is just to put my little component on the screen drawing pretty 3D things. I just wish I could have it play nice AND get decent performance at the same time!

Any advice for me?

Technically GLJPanel is hardware accelerated, it is just slow because of all the copying involved. Try using JPopupMenu.setDefaultLightWeightPopupEnabled(false) before you make your popup menus and use a GLCanvas.

There are two Swing workarounds for overlapping problems :

TooltipManager.sharedInstance().setLightWeightPopupEnabled(false); // for tooltips
JPopupMenu.setDefaultLightWeightPopupEnabled(false). // for menus and pop-ups

But they won’t help you if you use some kind of overlapping JComponents (JScrollPane and JInternalFrame mainly) .

I’ve developped for my company a framework to resolve that problem : we are using it to include JOGL canvases into a Swing docking desktop (GPL-like dual-licensing). Look at the java web start JOGL demo to have a idea of what it looks like.

Lilian

Thank you guys so much! GKW, your solution fixed the problem I had. If other things need to happen in the future that go on top of my Canvas, then c_lilian, your information will be used. I’ll keep that around just in case!

This is pretty cool. Works exactly as expected. Is everything else besides the JOGL window a lightweight widget? Do you promote the surrounding windows to heavyweights when they overlap the heavyweight widget?

Yes, I managed to have a heavy awt panel as a container for all dockable objects when overlapping may occurs (i.e. maximizing, auto-expand effect, drag and drop), and fall back to lightweight containers when no ovelapping is possible.

Some bugs remain in swing’s light-heavy mixing repaint management, I’ve worked around with a good set of repaint() at problematic places.

Next version will improve again in a order of magnitude… but I can’t comment on the feature set yet. :wink:

Lilian

For clarification, the ‘t’ in Tip should be capitalized… so,
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); // for tooltips

Hi!

I’m just testing the use of this nice framework for my “wave-editor”-project for the university, and came across a little problem
which I couldn’t solve yet. Whenever I minimize a Dock containing a GLCanvas and maximize it again, the whole content is not displayed,
even though display() is called correctly. The only thing I see is the “frame” of the GLCanvas, in pure white. Anybody who had the same problem?
Thank you for reading.

Greetings

basti

Hi ! and thanks for trying VLDocking

You’d better post in the product’s forum…

Anyway, i suppose you’re running on linux and using an animator.

If it’s the case, there is a race condition between JOGL and Swing that can be solved by putting a Thread.yield() in the animator loop (or may be in the display method).

If it’s not the case or doesn’t solve your problem, please continue this discussion in the appropriate forum where this information will be shared with our other users. :wink:

Thanks

Lilian

[edited] had a bad night, the original post reflected it too much…