summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-09-28 01:52:39 +0200
committerSven Gothel <[email protected]>2013-09-28 01:52:39 +0200
commitc8abb9d2c9a8c92f0c5c42aba13e3e80c69739dc (patch)
tree7997091175868b945f714094fb62cd09a08552bb
parentc943c8cfc39df64ec6682722e86a54c538d3497b (diff)
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.
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java13
3 files changed, 24 insertions, 1 deletions
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
@@ -337,8 +337,13 @@ 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.
* <p>
@@ -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);