Best approach for multiple GLCanvas + Swing + multi-screen

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Best approach for multiple GLCanvas + Swing + multi-screen

ZeLonewolf
Hello!

I am working on an application which, as currently implemented, has 5 GLCanvas objects spread across 3 monitors.  I use a single shared context for texture loading.  Each monitor has a JFrame which includes one or more GLCanvas objects as well as a multitude of Swing components.  I have found that as long as the Swing components are not repainting often, the GLCanvas objects run quite fast.  However, once the Swing components start repainting frequently, the GLCanvas frame rate goes WAY down (into the 1-3fps range).  From what I have researched, it sounds like all of the GLCanvas objects as well as all of the ordinary Swing repainting is happening in the same thread, which is the source of the performance bottleneck.

So what I'm trying to figure out is...what is the best approach for combining JoGL and Swing in the same application in such a way as to maximize the performance of the GL part?  Should I try to change the threading somehow?  Use something from NEWT?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Best approach for multiple GLCanvas + Swing + multi-screen

Brandon Borkholder
So what I'm trying to figure out is...what is the best approach for combining JoGL and Swing in the same application in such a way as to maximize the performance of the GL part?  Should I try to change the threading somehow?  Use something from NEWT?

One possible approach would be to draw all your Swing components into the same canvas as your other OpenGL graphics.  GLG2D lets you render Swing directly into a JOGL canvas.  It's not feature-complete, but I'm actively developing it.  There are two significant benefits to this:
  1. You have better control over when Swing draws (e.g. 30fps) and Swing won't clog the EDT queue with repaint requests
  2. Drawing Swing using glg2d is actually faster in some cases, specifically if you're rendering something complex in a single pass
Reply | Threaded
Open this post in threaded view
|

Re: Best approach for multiple GLCanvas + Swing + multi-screen

ZeLonewolf
That is phenomenal that you were able to make that work.  I plan on giving this a try!