Offscreen image inverted

My application requires OpenGL be rendered to an offscreen drawable and then to the screen. On most OS this works fine. But one user with OpenSuse 10.2 complains that the images drawn this way are inverted. No other platform sees it.

Here is a code extract:

	GLCapabilities glCap = new GLCapabilities();
	glCap.setRedBits(8);
	glCap.setGreenBits(8);
	glCap.setBlueBits(8);
	glCap.setAlphaBits(8);
	glCap.setDoubleBuffered(false);

	GLDrawableImpl offscreenDrawable = GLDrawableFactoryImpl.getFactoryImpl().createOffscreenDrawable(glCap, new DefaultGLCapabilitiesChooser() );
    offscreenDrawable.setSize(width,  height);
    GLContext glContext = (GLContextImpl) offscreenDrawable.createContext(null);

		glContext.makeCurrent();
		GL gl = glContext.getGL();
		joglComponent.initGL(gl);
		joglComponent.drawGL(offscreenDrawable, gl);
		BufferedImage img = Screenshot.readToBufferedImage(width,height);
		int xOffset =  context.getHorizontalOffset();
		int yOffset = context.getVerticalOffset();
		// The img is reflected in the y direction so we need to reflect it back
		Graphics2D g2 = (Graphics2D)g.create();
		int xShift = xOffset+width/2; // make the shift integer so that the image is preserved as much as possible
		                            // and not interpolated.
		int yShift = yOffset+height/2;
		g2.translate(xShift,yShift );
		g2.scale(1.0,-1.0);
		g2.translate(-xShift, -yShift);
		g2.drawImage(img,xOffset, yOffset, null);

Any ideas welcome.

Actually, after reading pixels from the frame buffer the ScreenShot flip the image vertically. However, depending on the hardware configuration, the flip might not be needed.
The flip is correctly handled in the GLJPanel class but not in the ScreenShot class.

By reading the GLJPanel class, I made a workaround for the bug. The information is actually in tyhe GLContext but is hidden.


BufferedImage dump = Screenshot.readToBufferedImage(getWidth(), getHeight()); // create the image
boolean needFlip;
try {
       // here is the information
	// raises an exception if hardware acceleration is on
	needFlip = !((GLContextImpl)GLContext.getCurrent()).offscreenImageNeedsVerticalFlip();
} catch (GLException e) {
	// hardware acceleration is on
	needFlip = false;
}
if (needFlip) {
	// flip it back
	ImageUtil.flipImageVertically(dump);
}
try {
	ImageIO.write(dump, getFileExtension(), file);
} catch (IOException e) {
	return ExportRenderer.IOEXCEPTION_ERROR;
}