public void releaseCurrentContext() { if (_context.equals(GLContext.getCurrent())) { try { _context.release(); } catch (final GLException gle) { gle.printStackTrace(); } } }
private static void dumpGLInfo(final GLDrawableFactoryImpl factory, final AbstractGraphicsDevice device) { final GLContext ctx = factory.getOrCreateSharedContext(device); if(null != ctx) { System.err.println("GLProfile.dumpGLInfo: "+ctx); ctx.makeCurrent(); try { System.err.println(JoglVersion.getGLInfo(ctx.getGL(), null)); } finally { ctx.release(); } } else { System.err.println("GLProfile.dumpGLInfo: shared context n/a"); } }
public void close() { try { if (GLContext.getCurrent() != null) { // Release the OpenGL resources. GLContext.getCurrent().release(); } } catch (final GLException releaseFailure) { logger.log(Level.WARNING, "Failed to release OpenGL Context: " + _glCanvas, releaseFailure); } finally { _glCanvas = null; } // Dispose of any window resources. dispose(); }
/** * 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 void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer, int width, int height) { canvas_.getContext().makeCurrent(); renderer_.onPaint(canvas_.getGL().getGL2(), popup, dirtyRects, buffer, width, height); canvas_.getContext().release(); SwingUtilities.invokeLater(new Runnable() { public void run() { canvas_.display(); } }); }
if( sharedGLCtxCurrent ) { postNextTextureImpl(sharedGLCtx.getGL()); sharedGLCtx.release();
j2dContext.release();
sharedContext.release(); } else { sharedDrawable.unlockSurface();
sharedContext.release();
lastContext.release();
final GLContext lastContext = GLContext.getCurrent(); if (lastContext != null) { lastContext.release();
} finally { try { ourContext.release(); if(ctxSwitch) { curContext.makeCurrent();
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() {