Skip to content

Commit

Permalink
TileRendererBase.GLEL.display(): Skip tile-rendering if TR is not yet…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
sgothel committed Sep 27, 2013
1 parent c943c8c commit c8abb9d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Expand Up @@ -89,6 +89,11 @@ public void setTileRect(int tX, int tY, int tWidth, int tHeight) throws IllegalS
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
Expand Down
7 changes: 6 additions & 1 deletion src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java
Expand Up @@ -336,9 +336,14 @@ public final void setRowOrder(int order) {
}
}

@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);
Expand Down
13 changes: 13 additions & 0 deletions src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
Expand Up @@ -313,6 +313,13 @@ public final void setImageBuffer(GLPixelBuffer buffer) {
}
}

/**
* 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>
Expand Down Expand Up @@ -577,6 +584,12 @@ public void dispose(GLAutoDrawable drawable) {
}
@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);
Expand Down

0 comments on commit c8abb9d

Please sign in to comment.