GLJPanel: No hardware acceleration

Hi,

I have a notebook with an ATI Mobility Radeon 9700. Under Windows, the GLJPanel is fast. Under linux, it’s extremly slow, but GLCanvas is very fast and so I think my drivers are ok. I have to use the Swing component, because I use JTextPanes with transparent background within the panel (wow, it’s extemely fast, I wouldn’t have believed that before!)

Now I try to find the reason for the low speed in Linux. I heard, GLJPanel needs pbuffer-support.

First question: Does JOGL support the GLX 1.3 pbuffers (standard), or the SGI extension, or both?

Thanks,

Andi

EDIT: Thread title changed, because other computer with windows is affected too.

You can find out what extensions are supported by typing “glxinfo” into a terminal. It’ll print out a whole load of stuff though, so you’d best pipe it into less like so : “glxinfo | less”

I tried

glxinfo | grep pbuffer

but I did not get any results. But the OpenGL version is 1.3, so pbuffers are regular part of OpenGL, aren’t they?
So I asked, if this is recognized by JOGL too.

Does it help when I post the complete output of glxinfo here?
Or is there any possibility to know why exactly acceleration within the GLJPanel fails?

If you specify -Djogl.debug.GLJPanel on the command line you should get more diagnostic output of how it is working.

GLJPanel.addNotify()
javax.media.opengl.GLException: pbuffer creation error: glXCreatePbuffer() failed
	at com.sun.opengl.impl.x11.X11PbufferGLDrawable.createPbuffer(X11PbufferGLDrawable.java:162)
	at com.sun.opengl.impl.x11.X11PbufferGLDrawable.<init>(X11PbufferGLDrawable.java:73)
        //...

I wonder why… All JOGL demos work great, even those that need pbuffer support!

Additional problem on other computer (Windows, no name video card: SiS Mirage Graphics, but drivers are from 02/2007): GLJPanel is always black. No error messages, just normal messages like “GLJPanel.handleReshape: (w,h) = (1392,845)”, “glViewport(0, 0, 1392, 845)” and so on…

GLCanvas works great in both cases.

Is there still work done with GLJPanel to improve its compatibility? Or do I have to buy new computers? :wink:
Thanks.

EDIT: I have found a way to use GLCanvas, too. It’s not looking as good as with GLJPanel, but it’s ok. Is there a possibility to find out if GLJPanel supports hardware acceleration? Something like

if (GLJPanel.tryHardwareAcc()) useGLJPanel(); else useGLCanvas();

SiS’s OpenGL drivers are notoriously bad – I don’t have much hope of the GLJPanel working on them.

For one of the JavaOne demos we built (which will be open-sourced soon), which incorporated some 3D graphics, we went through several iterations to try to get the best compatibility on most Windows computers. You can write a class which tries to fetch information about the OpenGL vendor and whether pbuffer support is available. Here’s a small code snippet so you get the idea. Note that we ended up never using the GLJPanel on Windows machines in our application due to spotty pbuffer support, although you might consider a different policy.


    public static synchronized void init() {
        if (!initialized && !initializing) {
            initializing = true;
            // See whether we have pbuffer support
            GLDrawableFactory factory = GLDrawableFactory.getFactory();
            if (factory.canCreateGLPbuffer()) {
                try {
                    pbuffer = factory.createGLPbuffer(new GLCapabilities(), null, 1, 1, null);
                    pbuffer.addGLEventListener(new InfoListener());
                    pbuffer.display();
                    havePbufferSupport = true;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            if (havePbufferSupport) {
                // See whether we want to rely on it

                // NOTE: for the time being we are completely
                // disabling the use of the lightweight component in
                // the 3-D display shelf on Windows, in order to
                // achieve the highest performance and best
                // compatibility on the widest range of graphics chips
                // and OpenGL driver versions. The only tangible
                // side-effect of this is a brief flash when we switch
                // between the 2-D editor view and the 3-D display
                // shelf view, which is relatively minor (though we
                // strive to avoid it on Mac OS X where OpenGL support
                // is broadly better).

                if (isWindows) {
                    havePbufferSupport = false;
                }

                /*
                if (isWindows &&
                    (isVista ||
                     (!isNVOrATI ||
                      !haveGL14))) {
                    havePbufferSupport = false;
                }
                */
            }

            if (!havePbufferSupport) {
                if (pbuffer != null) {
                    // Clean it up
                    try {
                        pbuffer.destroy();
                    } catch (GLException e) {
                        e.printStackTrace();
                    }
                    pbuffer = null;
                }

                initialized = false;

                // Different approach: create a 1x1 undecorated Frame
                // containing a GLCanvas and use this to query
                // OpenGL-related information; NOTE that we no longer
                // try to use this to keep textures and display lists
                // persistent in the slide show or display shelf due
                // to Intel's buggy OpenGL drivers on Windows Vista as
                // well as wanting to keep the code as stateless as
                // possible
                final Frame frame = new Frame("Iris OpenGL helper frame");
                frame.setLayout(new BorderLayout());
                frame.setUndecorated(true);
                GLCanvas canvas = new GLCanvas();
                canvas.addGLEventListener(new InfoListener());
                frame.add(canvas, BorderLayout.CENTER);
                frame.setSize(1, 1);
                frame.setLocation(0, 0);
                frame.setResizable(false);
                frame.setVisible(true);
                // I'm not sure why we seem to have to drive this manually, but doing so seems to work
                canvas.display();
                if (!initialized) {
                    System.out.println("OpenGLInfo: WARNING: setVisible() didn't execute synchronously");
                }
                EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            frame.dispose();
                        }
                    });
            }
        }
    }

    /** Indicates whether we think we can rely on pbuffer (and,
        therefore, GLJPanel) support on this machine. */
    public static boolean havePbufferSupport() {
        return havePbufferSupport;
    }