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.