/** * 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); } }
throw new GLException("Release current exclusive Context Thread "+exclusiveContextThread+" first"); if( null != context && context.isCurrent() ) { try { forceNativeRelease(context);
@Override public final void display(GLAutoDrawable drawable) { if (!drawable.getContext().isCurrent()) { return; } try { customRender(); } catch (Throwable ex) { logger.error("Error in custom code!", ex); } GLAnimatorControl ani = drawable.getAnimator(); //TODO GameTime updates einbaun logger.trace(String.format("%d Objects took %dms to render; fps:%f", robjekts.size(), ani.getLastFPSPeriod(), ani.getLastFPS())); if (info != null) { info.setFPS(ani.getTotalFPS()); } float delta = ani.getLastFPSPeriod(); for (ShaderUniform su : animated) { su.setData(delta); } if (info != null) { info.setMemInfo(meminfo); } }
public void init(GLAutoDrawable drawable) { vtkAbstractJoglComponent.this.isWindowCreated = true; // Make sure the JOGL Context is current GLContext ctx = drawable.getContext(); if (!ctx.isCurrent()) { ctx.makeCurrent(); } // Init VTK OpenGL RenderWindow vtkAbstractJoglComponent.this.glRenderWindow.SetMapped(1); vtkAbstractJoglComponent.this.glRenderWindow.SetPosition(0, 0); vtkAbstractJoglComponent.this.setSize(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); vtkAbstractJoglComponent.this.glRenderWindow.OpenGLInit(); }
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() {