GLCanvas vs GLJPanel

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

GLCanvas vs GLJPanel

Alex Crossley
I know I am going to sound like a rookie here with this question but... is there any way to make GLCanvas behave like GLJPanel so we can have the rendering surface in the same JFrame with other swing (GUI) controls?
You might say: just use GLPanel but that has some limitations that I cannot live with. Is there a trick anyone here can share to use GLCanvas as a "JPanel"? Much appreciated!
Reply | Threaded
Open this post in threaded view
|

Re: GLCanvas vs GLJPanel

Martin
That would be interesting to know why you can not live with GLCanvas! On my side I avoid using GLJPanel which has the first 2-3 frames a bit darker than expected.

In the past I faced incompatibilities of JOGL canvases with Miglayout. This led me to create a fallback canvas based on GL rendered offscreen and image copied to a JPanel (more here : https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-native-jogl-swing/src/main/java/org/jzy3d/chart/fallback). It is probably less efficient than using a real JOGL canvas, but at least it did not fail to resize with Miglayout! Maybe that can inspire you if you need a lightweight 3D canvas.
Reply | Threaded
Open this post in threaded view
|

Re: GLCanvas vs GLJPanel

gouessej
Administrator
In reply to this post by Alex Crossley
Please elaborate. Which limitations are you talking about?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLCanvas vs GLJPanel

Alex Crossley
GLJPanel is limited to 16 bit for Z-depth while GLCanvas can handle 24 bit which is a big help for "Z-fighting" effects, especially in a large environment.
Reply | Threaded
Open this post in threaded view
|

Re: GLCanvas vs GLJPanel

Alex Crossley
In reply to this post by Martin
Thanks Martin for your reply. I'll investigate your suggestion; very interesting ... but I suspect that would take a GPU to CPU image transfer for every frame which might be too heavy for my application running at 50Hz, but I'll give that a try. Thank you again and thanks for sharing the github link.
Reply | Threaded
Open this post in threaded view
|

Re: GLCanvas vs GLJPanel

Martin
Can't you customize capabilities with Swing up to 24 bits ?

GLProfile glp = ...
GLCapabilities caps = new GLCapabilities(glp);
caps.setDepthBits(24);

I haven't tested if my fallback stuff is able to reach 50Hz - charting is usually not demanding so much.