public static final GL2 getCurrentGL2() throws GLException { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } return curContext.getGL().getGL2(); }
public void surfaceUpdated(Object updater, NativeWindow window, long when) { if (updater instanceof GLDrawable) { GLDrawable drawable = (GLDrawable) updater; GLContext ctx = GLContext.getCurrent(); if (null != ctx && ctx.getGLDrawable() == drawable) { GL gl = ctx.getGL(); // FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec gl.glFinish(); readBufferUtil.fetchOffscreenTexture(drawable, gl); gl.glFinish(); try { surface2File("shot"); } catch (IOException ex) { throw new RuntimeException("can not write survace to file", ex); } } } }