PBuffer Creation

Hi,

I have been having some problems when i try to create a PBuffer in the following code snippet, it is throwing an exception on the last line:


  public synchronized void dumpImage(final int val, final int width, final int height, final String dumpname)
  {
    if (!GLDrawableFactory.getFactory().canCreateGLPbuffer()) {
      System.err.println("Error: canvas does not support off-screen drawables.");
      return;
    }

    boolean oldOffScreen = offScreen;

    offScreen = true;

    Dimension oldSize = new Dimension(screenDim);
    java.awt.Point oldScreenCorner = new java.awt.Point(screenCorner);

    screenDim.height = height;
    screenDim.width = width;

    screenCorner.x = 0;
    screenCorner.y = 0;

    GLCapabilities cap = new GLCapabilities();

    setCapabilities(cap, false, true);

    // Creates an offscreen canvas with an empty context that gets created later.
    final GLPbuffer offScreenCanvas = GLDrawableFactory.getFactory().createGLPbuffer(cap, width, height, null);

Where setCapabilitiies() is:


  private final void setCapabilities(GLCapabilities cap, final boolean stereo, final boolean offScreen) {
    cap.setDepthBits(24);
    // 24 bit colour:
    cap.setRedBits(8);
    cap.setBlueBits(8);
    cap.setGreenBits(8);
    cap.setAlphaBits(8);

    cap.setAccumRedBits(16);
    cap.setAccumGreenBits(16);
    cap.setAccumBlueBits(16);
    cap.setAccumAlphaBits(16);

    // we only need one stencil bit. But we'll see how many we get...
    cap.setStencilBits(8);

    if (offScreen) // Off screen renderring
      cap.setDoubleBuffered(false);
    else {
      cap.setDoubleBuffered(true);
      // Uncomment this for stereo visual
      if(stereo)
        cap.setStereo(true);
    }
  }

I get the following exception:

Exception occurred during event dispatching:
javax.media.opengl.GLException: pbuffer creation error: Couldn’t find a suitable pixel format
at com.sun.opengl.impl.windows.WindowsPbufferGLDrawable.createPbuffer(WindowsPbufferGLDrawable.java:285)
at com.sun.opengl.impl.windows.WindowsPbufferGLDrawable.(WindowsPbufferGLDrawable.java:77)
at com.sun.opengl.impl.windows.WindowsGLDrawableFactory$2.run(WindowsGLDrawableFactory.java:145)
at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.maybeDoSingleThreadedWorkaround(WindowsGLDrawableFactory.java:212)
at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.createGLPbuffer(WindowsGLDrawableFactory.java:162)
at com.baesystems.cfdsystems.draw.JOGL_GLwnd.dumpImage(JOGL_GLwnd.java:278)
at com.baesystems.cfdsystems.draw.GLwnd.setDump(GLwnd.java:2257)

I have no experience of pbuffers and am not sure why it is throwing this exception.

The pc i am running this on is a Windows XP machine with the following graphics settings:

Graphics Card Vendor: Intel
Graphics Card Version: Intel 915G
OpenGL Version: 1.4.0 - Build 4.14.10.4396

Any help or suggestions would be greatfully recieved.

Thanks
Mike

You’re trying to allocate a pbuffer with a lot of fancy features like stencil bits and an accumulation buffer. I wouldn’t be surprised if your Intel chipset didn’t support these features at least for pbuffers. Try installing NVidia’s NVPixelFormat or another utility and see what pixel formats are available and what the capabilities are of the pbuffer-capable formats.

If in doubt just reduce the capabilities for now. You can initialise OpenGL with empty GLCapabilities object:

GLCapabilities capabilities = new GLCapabilities();
canvas = new GLCanvas(capabilities);

As Ken mentioned I wouldn’t expect too much from the Intel chipset with regards to range of OpenGL features. In most cases even the most basic ATI chip usually has more features than your average Intel chipset, based on my experience.

stencil bufferes are definitivly not supported on Intel HW, one of the reasons why the Java2d team moved to depth-buffere for rendeing their clipping-shape into.
Is there no way of getting a list of supported pixel formats instead of asking for a hardwired one?

lg Clemens

JOGL doesn’t currently support the GLCapabilitiesChooser when choosing pbuffers’ pixel formats. We should fix this in a future release and in the public JSR-231 API even if the GLCapabilitiesChooser isn’t called right now. I’ll ask the expert group to approve this change.

Thanks very much for the help and explanation.

Thanks
Mike