Getting an Image from a GLCanvas

I’m trying to create an offscreen GLCanvas and then get an Image file which would basically be a picture of what’s in that GLCanvas. However, so far I haven’t been able to figure out how to get it to work. The method for getting an Image from a normal Canvas won’t work since GLCanvas uses a GLDrawable object instead of a Graphics object.

The low level OpenGL way for reading back the contents of the GLCanvas is through glReadPixels. There’s no need to do this yourself though. The JSR-231 implementation comes with a handy utility class called com.sun.opengl.util.Screenshot that manages this for you and returns a BufferedImage…