diff options
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 7 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 45 |
2 files changed, 20 insertions, 32 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 1f5c26f27..70157fe4b 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -105,7 +105,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; - private AWTWindowClosingProtocol awtWindowClosingProtocol = + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -204,7 +204,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return false; // NEWT shall proceed requesting the native focus } } - private FocusAction focusAction = new FocusAction(); + private final FocusAction focusAction = new FocusAction(); WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override @@ -559,8 +559,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 8c1110ed3..4f259fe9a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -499,21 +499,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind if( ( null != context ) ) { throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this); } - final NativeSurface ns; - { - final NativeSurface wrapped_ns = window.getWrappedSurface(); - ns = null != wrapped_ns ? wrapped_ns : window; - } - final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); - if(null==factory) { - factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); - } - drawable = (GLDrawableImpl) factory.createGLDrawable(ns); - drawable.setRealized(true); + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + final NativeSurface ns; + { + final NativeSurface wrapped_ns = window.getWrappedSurface(); + ns = null != wrapped_ns ? wrapped_ns : window; + } + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); + if(null==factory) { + factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); + } + drawable = (GLDrawableImpl) factory.createGLDrawable(ns); + drawable.setRealized(true); - if( !GLWindow.this.pushGLEventListenerState() ) { - context = (GLContextImpl) drawable.createContext(sharedContext); - context.setContextCreationFlags(additionalCtxCreationFlags); + if( !GLWindow.this.restoreGLEventListenerState() ) { + context = (GLContextImpl) drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + } } } if(Window.DEBUG_IMPLEMENTATION) { @@ -573,25 +576,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind // OpenGL-related methods and state // - private GLContext sharedContext = null; - @Override protected final RecursiveLock getLock() { return window.getLock(); } - /** - * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.<br> - * At native creation, {@link #setVisible(boolean) setVisible(true)}, - * a {@link javax.media.opengl.GLDrawable drawable} and {@link javax.media.opengl.GLContext context} is created besides the native Window itself,<br> - * hence you shall set the shared context before. - * - * @param sharedContext The OpenGL context shared by this GLWindow's one - */ - public void setSharedContext(GLContext sharedContext) { - this.sharedContext = sharedContext; - } - @Override public void display() { if( !isNativeValid() || !isVisible() ) { return; } |