diff options
5 files changed, 67 insertions, 18 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index 956693c4a..634cfeaed 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -150,7 +150,7 @@ public class GLDrawableUtil { } /** - * Return a heuristic value whether switching the {@link GLContext} is safe between {@lin GLAutoDrawable}s, + * Return a heuristic value whether switching the {@link GLContext} is safe between {@link GLAutoDrawable}s, * i.e. via {@link #swapGLContext(GLAutoDrawable, GLAutoDrawable)} or {@link #swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)}. * <p> * Method currently returns <code>false</code> if: diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 563158a72..a648e3bf6 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -82,6 +82,7 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.GLSharedContextSetter; @@ -893,11 +894,22 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } if( reqNewGLAD ) { final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); - GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); - printDrawable = printGLAD.getDelegatedDrawable(); + GLOffscreenAutoDrawable offGLAD = null; + try { + offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); + } catch (final GLException gle) { + if( DEBUG ) { + System.err.println("Caught: "+gle.getMessage()); + gle.printStackTrace(); + } + } + if( null != offGLAD ) { + printGLAD = offGLAD; + GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); + } } printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 5bc4c9a60..126513ec7 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -753,11 +753,22 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if( reqNewGLAD ) { final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); - GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); - printDrawable = printGLAD.getDelegatedDrawable(); + GLOffscreenAutoDrawable offGLAD = null; + try { + offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); + } catch (final GLException gle) { + if( DEBUG ) { + System.err.println("Caught: "+gle.getMessage()); + gle.printStackTrace(); + } + } + if( null != offGLAD ) { + printGLAD = offGLAD; + GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); + } } printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() ); printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 8d65f16d3..b51f290e9 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -275,7 +275,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLCapabilitiesChooser chooser, final int width, final int height) { final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); - drawable.setRealized(true); + try { + drawable.setRealized(true); + } catch( final GLException gle) { + try { + drawable.setRealized(false); + } catch( final GLException gle2) { /* ignore */ } + throw gle; + } if(drawable instanceof GLFBODrawableImpl) { return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null ); } @@ -285,7 +292,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { @Override public final GLAutoDrawable createDummyAutoDrawable(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser) { final GLDrawable drawable = createDummyDrawable(deviceReq, createNewDevice, capsRequested, chooser); - drawable.setRealized(true); + try { + drawable.setRealized(true); + } catch( final GLException gle) { + try { + drawable.setRealized(false); + } catch( final GLException gle2) { /* ignore */ } + throw gle; + } final GLAutoDrawable sharedDrawable = new GLAutoDrawableDelegate(drawable, null, null, true /*ownDevice*/, null) { }; return sharedDrawable; } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 397c8109b..e7ef22473 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -56,6 +56,8 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; @@ -670,11 +672,21 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } if( reqNewGLAD ) { final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); - GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); - printDrawable = printGLAD.getDelegatedDrawable(); + GLOffscreenAutoDrawable offGLAD = null; + try { + offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); + } catch (final GLException gle) { + if( DEBUG ) { + System.err.println("Caught: "+gle.getMessage()); + gle.printStackTrace(); + } + } + if( null != offGLAD ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); + } } printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0); |