public void snapshot(int sn, GL gl, String fileSuffix, String destPath) {
      final GLDrawable drawable = gl.getContext().getGLReadDrawable();
      final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
      final String filenameAWT =
          getSnapshotFilename(
              sn,
              postSNDetail,
              drawable.getChosenGLCapabilities(),
              drawable.getWidth(),
              drawable.getHeight(),
              glReadBufferUtil.hasAlpha(),
              fileSuffix,
              destPath);
      if (swapBuffersBeforeRead) {
        drawable.swapBuffers();
        // Just to test whether we use the right buffer,
        // i.e. back-buffer shall no more be required ..
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
      } else {
        gl.glFinish(); // just make sure rendering finished ..
      }

      final boolean awtOrientation = drawable.isGLOriented();
      System.err.println(
          Thread.currentThread().getName()
              + ": ** screenshot: awtOrient/v-flip "
              + awtOrientation
              + ", swapBuffersBeforeRead "
              + swapBuffersBeforeRead
              + ", "
              + filenameAWT);

      final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
      final File fout = new File(filenameAWT);
      try {
        ImageIO.write(image, "png", fout);
      } catch (IOException e) {
        e.printStackTrace();
      }
      /**
       * final String filenameJGL = getSnapshotFilename(sn, "jgl",
       * drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
       * glReadBufferUtil.hasAlpha(), fileSuffix, destPath); glReadBufferUtil.write(new
       * File(filenameJGL));
       */
    }
Exemple #2
0
 @Override
 public boolean isGLOriented() {
   final GLDrawable _drawable = drawable;
   return null != _drawable ? _drawable.isGLOriented() : true;
 }