From 4ef53cf2ae509a625795bfa3a8982ce75e24e83a Mon Sep 17 00:00:00 2001
From: Sven Gothel true
if all tiles have been rendered or {@link #setup()}
* has not been called, otherwise false
.
diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
index 74e1df316..5b3644f59 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java
@@ -67,9 +67,9 @@ import jogamp.opengl.Debug;
* after calling {@link #beginTile(GL)}, See {@link #beginTile(GL)}.
*
- * If {@link #attachToAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, - * the {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int)} method - * is being called after {@link #beginTile(GL)}. + * If {@link #attachAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, + * the {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int)} method + * is being called after {@link #beginTile(GL)} for each rendered tile. * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL)}. *
*+ * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is not current. + *
+ * @param tr the associated {@link TileRendererBase} + * @see TileRendererBase#getAttachedDrawable() + */ public void addTileRendererNotify(TileRendererBase tr); - /** The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachFromAutoDrawable() detached} from a {@link TileRendererBase}. */ + + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachAutoDrawable() detached} + * from the given {@link TileRendererBase} instance. + *+ * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is not current. + *
+ * @param tr the disassociated {@link TileRendererBase} + * @see TileRendererBase#getAttachedDrawable() + */ public void removeTileRendererNotify(TileRendererBase tr); + + /** + * Called by the {@link TileRendererBase} during tile-rendering via an + * {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable}'s + * {@link GLAutoDrawable#display()} call for each tile before {@link #display(GLAutoDrawable)}. + *+ * The PMV Matrix shall be reshaped + * according to the given + *
+ * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is current. + *
+ * @param tr the issuing {@link TileRendererBase} + * @param tileX the {@link TileRendererBase#TR_CURRENT_TILE_X_POS current tile's x-pos} + * @param tileY the {@link TileRendererBase#TR_CURRENT_TILE_Y_POS current tile's y-pos} + * @param tileWidth the {@link TileRendererBase#TR_CURRENT_TILE_WIDTH current tile's width} + * @param tileHeight the {@link TileRendererBase#TR_CURRENT_TILE_HEIGHT current tile's height} + * @param imageWidth the {@link TileRendererBase#TR_IMAGE_WIDTH final image width} + * @param imageHeight the {@link TileRendererBase#TR_IMAGE_HEIGHT final image height} + * @see TileRendererBase#getAttachedDrawable() + */ + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight); + + /** + * Called by the {@link TileRendererBase} during tile-rendering + * after {@link TileRendererBase#beginTile(GL)} and before {@link #reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(..)}. + *
+ * If {@link TileRendererBase} is of type {@link TileRenderer},
+ * method is called for the first tile of all tiles.
+ * Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile.
+ *
+ * The {@link GLContext} of the {@link TileRenderer}'s {@link TileRenderer#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is current. + *
+ * @param tr the issuing {@link TileRendererBase} + */ + public void startTileRendering(TileRendererBase tr); + + /** + * Called by the {@link TileRenderer} during tile-rendering + * after {@link TileRendererBase#endTile(GL)} and {@link GLAutoDrawable#swapBuffers()}. + *
+ * If {@link TileRendererBase} is of type {@link TileRenderer},
+ * method is called for the last tile of all tiles.
+ * Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile.
+ *
+ * The {@link GLContext} of the {@link TileRenderer}'s {@link TileRenderer#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is current. + *
+ * @param tr the issuing {@link TileRendererBase} + */ + public void endTileRendering(TileRendererBase tr); } protected final Dimension imageSize = new Dimension(0, 0); @@ -246,13 +328,13 @@ public abstract class TileRendererBase { *@@ -311,12 +393,12 @@ public abstract class TileRendererBase { } /** - * Attaches this renderer to the {@link GLAutoDrawable}. + * Attaches the given {@link GLAutoDrawable} to this tile renderer. + *
+ * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to this tile renderer. + *
*
- * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to this tile renderer.
- * It is highly recommended that the original {@link GLEventListener} implement
- * {@link TileRendererNotify}, so they get {@link TileRendererNotify#addTileRendererNotify(TileRendererBase) notified}
- * about this event.
+ * {@link GLEventListeners} not implementing {@link TileRendererListener} are ignored while tile rendering.
*
* The {@link GLAutoDrawable}'s {@link GLAutoDrawable#getAutoSwapBufferMode() auto-swap mode} is cached @@ -324,15 +406,15 @@ public abstract class TileRendererBase { * see {@link #reqPreSwapBuffers(GLCapabilitiesImmutable)}. *
*
- * This tile renderer's {@link GLEventListener} is then added to handle the tile rendering,
- * replacing the original {@link GLEventListener}.
- * This {@link GLEventListener#display(GLAutoDrawable) display} implementations issues:
+ * This tile renderer's internal {@link GLEventListener} is then added to the attached {@link GLAutoDrawable}
+ * to handle the tile rendering, replacing the original {@link GLEventListener}.
+ * It's {@link GLEventListener#display(GLAutoDrawable) display} implementations issues:
*
- * The PMV Matrix shall be reshaped in the
- * original {@link GLEventListener}'s {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method
- * according to the tile-position, -size and image-size
- * The {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method is called for each tile
- * w/ the current viewport of tile-size, where the tile-position and image-size can be retrieved by this tile renderer,
- * see details in {@link #beginTile(GL)}.
- * The original {@link GLEventListener} implementing {@link TileRendererNotify} is aware of this
- * tile renderer instance.
- *
* Consider using {@link #setGLEventListener(GLEventListener, GLEventListener)} to add pre- and post
* hooks to be performed on this renderer {@link GLEventListener}.
* The pre-hook is able to allocate memory and setup parameters, since it's called before {@link #beginTile(GL)}.
@@ -359,13 +431,15 @@ public abstract class TileRendererBase {
* since it's called after {@link #endTile(GL)}.
*
- * Call {@link #detachFromAutoDrawable()} to remove this renderer from the {@link GLAutoDrawable} + * Call {@link #detachAutoDrawable()} to remove the attached {@link GLAutoDrawable} from this tile renderer * and to restore it's original {@link GLEventListener}. *
- * @param glad + * @param glad the {@link GLAutoDrawable} to attach. * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached + * @see #getAttachedDrawable() + * @see #detachAutoDrawable() */ - public void attachToAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { + public final void attachAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { if( null != this.glad ) { throw new IllegalStateException("GLAutoDrawable already attached"); } @@ -379,9 +453,9 @@ public abstract class TileRendererBase { listenersInit[i] = glad.getGLEventListenerInitState(l); listeners[i] = glad.removeGLEventListener( l ); final boolean trn; - if( listeners[i] instanceof TileRendererNotify ) { + if( listeners[i] instanceof TileRendererListener ) { trn = true; - ((TileRendererNotify)listeners[i]).addTileRendererNotify(this); + ((TileRendererListener)listeners[i]).addTileRendererNotify(this); } else { trn = false; } @@ -399,25 +473,34 @@ public abstract class TileRendererBase { } } - /** - * Detaches this renderer from the {@link GLAutoDrawable}. - *- * It is highly recommended that the original {@link GLEventListener} implement - * {@link TileRendererNotify}, so they get {@link TileRendererNotify#removeTileRendererNotify(TileRendererBase) notified} - * about this event. - *
+ /** + * Returns a previously {@link #attachAutoDrawable(GLAutoDrawable) attached} {@link GLAutoDrawable}, + *null
if none is attached.
* - * See {@link #attachToAutoDrawable(GLAutoDrawable)}. + * If called from {@link TileRendererListener#addTileRendererNotify(TileRendererBase)} + * or {@link TileRendererListener#removeTileRendererNotify(TileRendererBase)}, method returns the + * just attached or soon to be detached {@link GLAutoDrawable}. *
+ * @see #attachAutoDrawable(GLAutoDrawable) + * @see #detachAutoDrawable() + */ + public final GLAutoDrawable getAttachedDrawable() { + return glad; + } + + /** + * Detaches the given {@link GLAutoDrawable} from this tile renderer. + * @see #attachAutoDrawable(GLAutoDrawable) + * @see #getAttachedDrawable() */ - public void detachFromAutoDrawable() { + public final void detachAutoDrawable() { if( null != glad ) { glad.removeGLEventListener(tiledGLEL); final int aSz = listenersInit.length; for(int i=0; i