Updating Canvas

I’m sorry if this isn’t the most adequate forum to post this question, but here it goes :stuck_out_tongue: (sometimes it’s hard to dcide on which forum to post, since things normally overlap… but anyway:)

I’m using Xith, with JOGL. I added a PopupMenu to a GLCanvas, and the problem is that when I make the PopupMenu visible, the awt thread takes possession of the system and does not let my application update the GLCanvas as it would normally. The consequences are at least ungly gray marks on the screen.

I searched everywhere for something useful, and although people had similar problems in Java3D, I couldn’t find a answer.

Is there a way to tell a PopupMenu no to act this way? I thought about extending PopupMenu, and overriding show() or addNotify() but can’t really make it work :frowning:

Any suggestions? :stuck_out_tongue:

The drawing on the GLCanvas takes place on the video card making it impossible to place swing controls (including menus) on top of a GLCanvas. To see an example of this, place a menu in a JFrame make a GLCanvas fill out the rest of the window. The menus will be cut off when they cross over into the GLCanvas.

If you need swing controls you have to use a GLJPanel. Which is unfortunally very slow since it is being rendererd in software. As a compromise, you might want to draw stuff with a GLCanvas, but when the user tries to bring up a context menu to switch to a GLJPanel. I haven’t done this before, but I don’t see why it wouldn’t work. Another thing you might try (also haven’t tried to do this) is to create a undecorated/borderless window and position that on top of the GLCanvas and draw your context menu in that.

I think the situation of an AWT PopupMenu overlapping a GLCanvas should work fine as the PopupMenu component is heavyweight. You might want to try specifying -Dsun.java2d.noddraw=true on the command line to disable Java2D’s internal use of DirectDraw, but I don’t think that will change the behavior as that tends to affect Swing but not the AWT as much. How are you animating your GLCanvas? Since the PopupMenu is handled on the AWT thread you might need an Animator with its separate animation thread to keep your GLCanvas updating while the menu is visible.

For the issue of Swing menus not overlapping heavyweight components, you can use JPopupMenu.setLightweightPopupEnabled(false) to make this work.

Thanks milvich and Ken for the inputs.

milvich, I am aware of the issues regardind Swing and AWT components. Indeed, I’m currently using MenuBar (instead of its J counterpart) and I do use MenuItem and PoupMenu too. I think using an undecorated window and placing on GLCanvas would work, because I don’t think it would freeze my current thread. But I am not sure how I would implement that idea. I could be missing something, but is there an easy way to draw a component on GLCanvas? (Without using billboards or the UIOverlay scheme offered by Xith) There is an option of making my own GUI artifacts, but I’m choosing to go along with swing and awt for the moment. Just need to understand better how the AWT thread operates.

Ken, the noddraw settings didn’t help in my problem. But I’m curious on how these settings could affect overall performance. I’m right now googling to find settings that could play a role improving jogl performance ;D (do you know any?)

I have a Main class, which implements Runnable and runs my rendering loop. I add an ActionListener to my GLCanvas to show a PopupMenu. Normal Menus (from MenuBar) and modal dialogs do not freeze my rendering threads, only popup menus do. All my GUI related objects are created from the Main’s constructor (which is called in the main() method) before I create the running thread. So, I don’t see how creating another thread will be able to run along with popup menu. But I’ll try it anyway and see what happens. Thanks again!