From c8abb9d2c9a8c92f0c5c42aba13e3e80c69739dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 28 Sep 2013 01:52:39 +0200 Subject: TileRendererBase.GLEL.display(): Skip tile-rendering if TR is not yet setup. Sync issue w/ NEWT/AWT based GLAD NEWT based GLDrawables may trigger GLAD display() via native repaint events. If using in conjunction w/ AWT, i.e. NewtCanvasAWT and setupPrinting(..) has been called and it's attched to the TR .. it could happen that display tries to issue beginTile() before the TR is being setup. This patch mitigates this issue (while not removing it) by querying whether setup is completed. --- .../classes/com/jogamp/opengl/util/RandomTileRenderer.java | 5 +++++ src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java | 7 ++++++- .../classes/com/jogamp/opengl/util/TileRendererBase.java | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/jogl/classes/com/jogamp') diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index dcf229716..8fc7916c7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -89,6 +89,11 @@ public class RandomTileRenderer extends TileRendererBase { tileRectSet = true; } + @Override + public final boolean isSetup() { + return 0 < imageSize.getWidth() && 0 < imageSize.getHeight() && tileRectSet; + } + /** * {@inheritDoc} * @throws IllegalStateException if image-size or tileRect has not been set diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index 7c57627e9..f126eb7f5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -336,9 +336,14 @@ public class TileRenderer extends TileRendererBase { } } + @Override + public final boolean isSetup() { + return 0 < imageSize.getWidth() && 0 < imageSize.getHeight(); + } + @Override public final void beginTile( GL gl ) throws IllegalStateException, GLException { - if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { + if( !isSetup() ) { throw new IllegalStateException("Image size has not been set"); } validateGL(gl); diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index 5b3644f59..f00e59347 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -313,6 +313,13 @@ public abstract class TileRendererBase { } } + /** + * Returns true if this instance is setup properly, i.e. {@link #setImageSize(int, int)} .., + * and ready for {@link #beginTile(GL)}. + * Otherwise returns false. + */ + public abstract boolean isSetup(); + /** * Begins rendering a tile. *

@@ -577,6 +584,12 @@ public abstract class TileRendererBase { } @Override public void display(GLAutoDrawable drawable) { + if( !isSetup() ) { + if( DEBUG ) { + System.err.println("TileRenderer.glel.display: !setup: "+TileRendererBase.this); + } + return; + } if( null != glEventListenerPre ) { glEventListenerPre.reshape(drawable, 0, 0, currentTileWidth, currentTileHeight); glEventListenerPre.display(drawable); -- cgit v1.2.3