/** De-initialize in the OpenGL thread. */ protected void deinitInThread() { destroyContext(); listener.destroy(); logger.info("Display destroyed."); super.internalDestroy(); }
protected void deinitInThread() { renderable.set(false); listener.destroy(); renderer.cleanup(); pbuffer.destroy(); logger.fine("Offscreen buffer destroyed."); super.internalDestroy(); }
/** Does LWJGL display initialization in the OpenGL thread */ protected boolean initInThread() { try { if (!JmeSystem.isLowPermissions()) { // Enable uncaught exception handler only for current thread Thread.currentThread() .setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread thread, Throwable thrown) { listener.handleError( "Uncaught exception thrown in " + thread.toString(), thrown); if (needClose.get()) { // listener.handleError() has requested the // context to close. Satisfy request. deinitInThread(); } } }); } // For canvas, this will create a pbuffer, // allowing us to query information. // When the canvas context becomes available, it will // be replaced seamlessly. createContext(settings); printContextInitInfo(); created.set(true); super.internalCreate(); } catch (Exception ex) { try { if (Display.isCreated()) Display.destroy(); } catch (Exception ex2) { logger.log(Level.WARNING, null, ex2); } listener.handleError("Failed to create display", ex); return false; // if we failed to create display, do not continue } listener.initialize(); return true; }
protected void initInThread() { if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) { logger.severe("Offscreen surfaces are not supported."); return; } int samples = getNumSamplesToUse(); pixelFormat = new PixelFormat( settings.getBitsPerPixel(), 0, settings.getDepthBits(), settings.getStencilBits(), samples); width = settings.getWidth(); height = settings.getHeight(); try { Thread.setDefaultUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread thread, Throwable thrown) { listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown); } }); pbuffer = new Pbuffer(width, height, pixelFormat, null, null, createContextAttribs()); pbuffer.makeCurrent(); renderable.set(true); logger.fine("Offscreen buffer created."); printContextInitInfo(); } catch (LWJGLException ex) { listener.handleError("Failed to create display", ex); } finally { // TODO: It is possible to avoid "Failed to find pixel format" // error here by creating a default display. } super.internalCreate(); listener.initialize(); }