Hi,
Is there a way to take a synchronous screenshot from a GLJPanel component?
I'm using the GLJPanel in a framework, where I need to implement an interface which returns a screenshot. This means, I cannot create the screenshot in the "display(GLAutoDrawable ...)" method.
I have tried both:
BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
paint(image.createGraphics());
and
gl.getContext().makeCurrent();
BufferedImage image = Screenshot.readToBufferedImage(getWidth(), getHeight());
But the first one fails sometimes (returning messed up images). And I guess I cannot assume that holding a GL2 handle and calling makeCurrent() on its GLContext will succed?
So what is the proper way to get a screenshot outside of the display(...) method?
(I believe the GLJPanel creates a BufferedImage each time it renders to screen - is it possible to get a handle to the last rendered BufferedImage?)