/** * Since GLContext's {@link GLContext#makeCurrent()} and {@link GLContext#release()} * is recursive, a call to {@link GLContext#release()} may not natively release the context. * <p> * This methods continues calling {@link GLContext#release()} until the context has been natively released. * </p> * @param ctx */ public static final void forceNativeRelease(final GLContext ctx) { int releaseCount = 0; do { ctx.release(); releaseCount++; if (DEBUG) { System.err.println("GLDrawableHelper.forceNativeRelease() #"+releaseCount+" -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); } } while( MAX_RELEASE_ITER > releaseCount && ctx.isCurrent() ); if( ctx.isCurrent() ) { throw new GLException("Context still current after "+MAX_RELEASE_ITER+" releases: "+ctx); } }
/** * Since GLContext's {@link GLContext#makeCurrent()} and {@link GLContext#release()} * is recursive, a call to {@link GLContext#release()} may not natively release the context. * <p> * This methods continues calling {@link GLContext#release()} until the context has been natively released. * </p> * @param ctx */ public static final void forceNativeRelease(final GLContext ctx) { int releaseCount = 0; do { ctx.release(); releaseCount++; if (DEBUG) { System.err.println("GLDrawableHelper.forceNativeRelease() #"+releaseCount+" -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); } } while( MAX_RELEASE_ITER > releaseCount && ctx.isCurrent() ); if( ctx.isCurrent() ) { throw new GLException("Context still current after "+MAX_RELEASE_ITER+" releases: "+ctx); } }
@Override public V get(){ final GLContext context = canvas.getContext(); if(!super.isDone()) if( context != null ) { if(context.isCurrent()) run(); } else throw new IllegalStateException("GL Context is closed."); return super.get(); } }//end GLFutureTask
throw new GLException("Release current exclusive Context Thread "+exclusiveContextThread+" first"); if( null != context && context.isCurrent() ) { try { forceNativeRelease(context);
throw new GLException("Release current exclusive Context Thread "+exclusiveContextThread+" first"); if( null != context && context.isCurrent() ) { try { forceNativeRelease(context);
public int ExecuteGFXCommand(final int cmd, final int len, final byte[] cmddata, final int[] hasret) { if (pbuffer != null && !pbuffer.getContext().isCurrent() && Threading.isSingleThreaded() && !Threading.isOpenGLThread()) { final int[] retholder = new int[1]; Threading.invokeOnOpenGLThread(true, new Runnable() { public void run() { retholder[0] = ExecuteGFXCommandSync(cmd, len, cmddata, hasret); } }); return retholder[0]; } else return ExecuteGFXCommandSync(cmd, len, cmddata, hasret); } private int ExecuteGFXCommandSync(int cmd, int len, byte[] cmddata, int[] hasret)
public final synchronized void initGL(final GL gl) { final GLContext glCtx = gl.getContext(); final boolean glCtxCurrent = glCtx.isCurrent(); final GLProfile glp = gl.getGLProfile(); final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); final AbstractGraphicsDevice device = glCtx.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); dummyDrawable = factory.createDummyDrawable(device, true, glCtx.getGLDrawable().getChosenGLCapabilities(), null); // own device! dummyDrawable.setRealized(true); sharedGLCtx = dummyDrawable.createContext(glCtx); makeCurrent(sharedGLCtx); if( glCtxCurrent ) { makeCurrent(glCtx); } else { sharedGLCtx.release(); } } public final synchronized void doPause(final boolean waitUntilDone) {
if(!glContext.isCurrent()) { throw new IllegalArgumentException("OpenGL context is not current,\n"+ " creating a OpenCL context for context sharing is not allowed in this situation.");