Exception with java2d.opengl=true on Windows

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

Exception with java2d.opengl=true on Windows

Thibaud
Hello,

I'm trying to use GLJpanel on Windows. I start with this simple code:

-------------------------------------------------
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLJPanel;
import javax.swing.JFrame;

public class SimpleTest {
        public static void main(String[] args) {
                GLProfile glp = GLProfile.getDefault();
                GLCapabilities caps = new GLCapabilities(glp);
                GLJPanel panel = new GLJPanel(caps);

                JFrame frame = new JFrame("Test");
                frame.setSize(300, 300);
                frame.getContentPane().add(panel);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
        }
}
-------------------------------------------------

It works well until I enable -Dsun.java2d.opengl=true, and then I get this exception:

exception in QueueFlusher:
javax.media.opengl.GLException: Should not call this
        at jogamp.opengl.windows.wgl.WindowsExternalWGLDrawable.getWidth(WindowsExternalWGLDrawable.java:90)
        at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:636)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:560)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:517)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1020)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:909)
        at javax.media.opengl.awt.GLJPanel$J2DOGLBackend$3.run(GLJPanel.java:1823)
        at sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(OGLRenderQueue.java:202)

Does anyone know why? Is there somethink I missed?

I am on Windows 7 64bits, JDK 1.7_017, JOGL 2.0.2.

Thank you,

Thibaud
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

gouessej
Administrator
Hi

Don't enable any hardware accelerated Java2D pipeline if you don't want to have some troubles, especially under Windows. I disable both the one based on Direct3D and the one based on OpenGL.

Do you reproduce this bug with a more recent update of Java 1.7?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

Thibaud
Hello,

Yes I reproduce this bug with JDK 1.7_025.
It works if I disable Direct3D and OpenGL, but the rendering is very slow. I thought that I could use the JOGL/Java2D interoperability to get a fast lightweight component.

I found this thread http://www.java-gaming.org/index.php?topic=21988.0 which says that the JOGL/Java2D interoperability is not maintained anymore. Do you know if there is a way to have a hardware-accelerated lightweight component using JOGL, or do I have to use GLCanvas to improve performance?

Thibaud
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

gouessej
Administrator
At first, the thread you quote is very old and contains some comments that are parts of the famous FUD campaign against JOGL after Sun gave it up. As tons of people posted defamatory comments about JOGL on this forum, I had to ask the main moderator to close the JOGL section and to encourage people to come here instead. Java-Gaming.org was a nice place to speak about JOGL but so much developers against us spent a lot of time in hijacking our threads to promote their "craps", especially after Sun left the boat. It was a real nightmare and I felt a bit alone to defend JOGL. Even several moderators of Java-Gaming.org participated to this FUD campaign and one of them who doesn't like me to mention this dark piece of the history systematically tries to remove my comments and bans me when I succeed in doing so. I hope you understand that I'm really upset by this kind of "moderation". This forum should be renamed LW***-Gaming.org.

Secondly, I'm sorry but your remark about the "slowness" of the GLJPanel is probably a bit exaggerated, this lightweight component is maybe a bit slower without the build-in Java2D hardware acceleration but setting it on or off doesn't influence a lot the performance anyway.

Thirdly, I have always advised to use GLJPanel only in special cases, for example when you need to create internal frames. GLJPanel has a bigger memory footprint and is still often at least a bit slower than GLCanvas and GLWindow. FBOs are still slow on tons of machines and when GLJPanel uses FBOs, you're exposed to this problem.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

Thibaud
Hello,

OK. All theses old posts are a little confusing.

About the slowness of GLJPanel, it is really slow on my configuration, for a high definition window. As an example, the frame rate to draw a single triangle (http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing) is about 1fps for ~1M pixels.

Thank you for the advice. I think I will try again to use GLCanvas in my Swing application. Mixing HW and LW components seems less tricky since JDK 1.7.0_19.

Thibaud
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

gouessej
Administrator
What's your graphics card? I always try to stay far from FBOs (whose performance is horrible on lots of Intel chips and low end chipsets for laptops). Don't use JDK 1.7.0_19, rather use the latest update or you will accumulate technical "debt".
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

Thibaud
Well, it is an Intel chipset :-)
And unfortunately, my application has to work with it.
Thank you for your answers, it helped a lot.

Thibaud
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

gouessej
Administrator
Thibaud, I'm really sorry, I understand your position now. If you try to use WebGL whose implementations heavily rely on FBOs, you'll have horrible performance too :( I'm not surprised. Can you explain why you chose to use GLJPanel? Does a simple GLCanvas in a JPanel work in your case?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

Thibaud
A GLCanvas works but we had a bug during the graphic context initialization. It is not the first bug, that's why I tried a different way (using a full lightweight component). Considering the performance of FBOs on the Intel chipset, I'm back on the old way and try to fix the original initialization issue.

Thibaud
Reply | Threaded
Open this post in threaded view
|

Re: Exception with java2d.opengl=true on Windows

gouessej
Administrator
It's a wise choice in my humble opinion.
Julien Gouesse | Personal blog | Website