문제

I have Swing frame and some sprites drawn on it. I need to save this 2D scene as an image using JOGL but every tutorial I managed to find seems to be obsolete. I'm using JOGL 2.1.5.

도움이 되었습니까?

해결책

using Screenshot:

BufferedImage image = Screenshot.readToBufferedImage(width, height);

using AWTGLReadBufferUtil:

GLAutoDrawable glad = (GLAutoDrawable) event.getSource();
AWTGLReadBufferUtil glReadBufferUtil = new AWTGLReadBufferUtil(glad.getGLProfile(), false);
BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(glad.getGL(), true);

AWTGLReadBufferUtil example source

다른 팁

You can use AWTGLReadBufferUtil or Screenshot to do that. I advise you to look at the project jogl-demos on Github if you need an example. Screenshot was already available in JOGL 1 but is deprecated in JOGL 2.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top