@Override public final GLContext createContext(final GLContext shareWith) { return (null != offscreenDrawable) ? offscreenDrawable.createContext(shareWith) : null; }
@Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { if (offscreenDrawable == null) { return null; } return offscreenDrawable.getChosenGLCapabilities(); }
@Override public final GLProfile getGLProfile() { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.getGLProfile() : null; }
/** Begins the OpenGL rendering process for the overlay. This is separated out so advanced applications can render independent pieces of the overlay to different portions of the drawable. @throws GLException If an OpenGL context is not current when this method is called */ public void beginRendering() throws GLException { renderer.beginOrthoRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); }
private final void setRealizedImpl(final boolean realized) { final RecursiveLock _lock = lock; _lock.lock(); try { final GLDrawable _drawable = drawable; if( null == _drawable || realized == _drawable.isRealized() || realized && ( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) ) { return; } _drawable.setRealized(realized); if( realized && _drawable.isRealized() ) { sendReshape=true; // ensure a reshape is being send .. } } finally { _lock.unlock(); } } private final Runnable realizeOnEDTAction = new Runnable() {
panelWidth, panelHeight); updateWrappedSurfaceScale(offscreenDrawable); offscreenDrawable.setRealized(true); if( DEBUG_FRAMES ) { offscreenDrawable.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @Override public final void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) { flipVertical = !GLJPanel.this.skipGLOrientationVerticalFlip && offscreenDrawable.isGLOriented(); offscreenIsFBO = offscreenDrawable.getRequestedGLCapabilities().isFBO(); final boolean useGLSLFlip_pre = flipVertical && offscreenIsFBO && reqOffscreenCaps.getGLProfile().isGL2ES2() && USE_GLSL_TEXTURE_RASTERIZER; if( offscreenIsFBO && !useGLSLFlip_pre ) { offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]); offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant); final boolean useGLSLFlip = useGLSLFlip_pre && gl.isGL2ES2() && glslCompliant; offscreenDrawable.setRealized(false); offscreenDrawable = null;
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() {
private boolean validateGLDrawable() { if( Beans.isDesignTime() || !isDisplayable() ) { return false; // early out! } final GLDrawable _drawable = drawable; if ( null != _drawable ) { boolean res = _drawable.isRealized(); if( !res ) { // re-try drawable creation if( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) { return false; // early out! } setRealized(true); res = _drawable.isRealized(); if(DEBUG) { System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); // Thread.dumpStack(); } } if( res && null == context ) { // re-try context creation res = createContextImpl(_drawable); // pending creation. } return res; } return false; }
@Override public final void swapBuffers() { final GLDrawable d = offscreenDrawable; if( null != d ) { d.swapBuffers(); } }
/** * Convenient wrapper for {@link GLDrawableFactory#setDisplayGamma(javax.media.nativewindow.NativeSurface, float, float, float)}. * <p> * Use {@link #setDisplayGamma(GLAutoDrawable, float, float, float)} in case of using an {#link GLAutoDrawable}. * </p> */ public static boolean setDisplayGamma(final GLDrawable drawable, final float gamma, final float brightness, final float contrast) throws IllegalArgumentException { return GLDrawableFactory.getFactory(drawable.getGLProfile()).setDisplayGamma(drawable.getNativeSurface(), gamma, brightness, contrast); }
offscreenDrawable.swapBuffers(); if( offscreenDrawable.getSurfaceWidth() != panelWidth || offscreenDrawable.getSurfaceHeight() != panelHeight ) { throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getSurfaceWidth()+"x"+offscreenDrawable.getSurfaceHeight()+", on thread "+getThreadName());
reqStencil = 16; } else if( CHOSEN_BITS == reqBits ) { final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getChosenGLCapabilities(); reqDepth = caps.getDepthBits(); reqStencil = caps.getStencilBits(); } else if( REQUESTED_BITS == reqBits ) { final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getRequestedGLCapabilities(); reqDepth = caps.getDepthBits(); reqStencil = caps.getStencilBits();
@Override public boolean isRealized() { final GLDrawable _drawable = drawable; return (_drawable != null) ? _drawable.isRealized() : false; }
/** Default implementation to handle repaint events from the windowing system */ protected final void defaultWindowRepaintOp() { final GLDrawable _drawable = drawable; if( null != _drawable && _drawable.isRealized() ) { if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimatingOnOtherThread() ) { display(); } } }
final AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); if (factory.canCreateExternalGLDrawable(device)) { joglDrawable = factory.createExternalGLDrawable(); joglContext = joglDrawable.createContext(j2dContext); if (DEBUG) { System.err.println("-- Created External Drawable: "+joglDrawable);
private void destroySharedGL() { if( null != sharedGLCtx ) { if( sharedGLCtx.isCreated() ) { // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. try { sharedGLCtx.destroy(); } catch (final GLException gle) { gle.printStackTrace(); } } sharedGLCtx = null; } if( null != dummyDrawable ) { final AbstractGraphicsDevice device = dummyDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); dummyDrawable.setRealized(false); dummyDrawable = null; device.close(); } }
@Override public NativeSurface getNativeSurface() { final GLDrawable _drawable = drawable; return (null != _drawable) ? _drawable.getNativeSurface() : null; }
@Override public long getHandle() { final GLDrawable _drawable = drawable; return (null != _drawable) ? _drawable.getHandle() : 0; }
@Override public GLDrawableFactory getFactory() { final GLDrawable _drawable = drawable; return (_drawable != null) ? _drawable.getFactory() : null; }
@Override public final GLCapabilitiesImmutable getRequestedGLCapabilities() { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.getRequestedGLCapabilities() : null; }