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*/ -public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererNotify { +public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererListener { private final FloatBuffer lightPos = Buffers.newDirectFloatBuffer( new float[] { 5.0f, 5.0f, 10.0f } ); private ShaderState st = null; @@ -84,15 +85,25 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("GearsES2.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("GearsES2.endTileRendering: "+tr); + } public void setIgnoreFocus(boolean v) { ignoreFocus = v; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } @@ -136,6 +147,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN public GearsObjectES2 getGear3() { return gear3; } + @Override public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.init: tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -233,18 +245,29 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN System.err.println(Thread.currentThread()+" GearsES2.init FIN"); } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - final GL2ES2 gl = drawable.getGL().getGL2ES2(); + @Override + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); - System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); - - drawableHeight = height; + System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + drawableHeight = imageHeight; - // Thread.dumpStack(); - - if(-1 != swapInterval) { - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) - } if( !gl.hasGLSL() ) { return; } @@ -253,23 +276,6 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - gl.setSwapInterval(swapInterval); - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } - // compute projection parameters 'normal' float left, right, bottom, top; if( imageHeight > imageWidth ) { @@ -312,6 +318,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN } // private boolean useAndroidDebug = false; + @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse); final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -339,6 +346,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN System.err.println(Thread.currentThread()+" GearsES2.dispose FIN"); } + @Override public void display(GLAutoDrawable drawable) { GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 40e9876ea..715a97d63 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -34,13 +34,14 @@ import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; + import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLUniformData; -public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRendererNotify { +public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRendererListener { private ShaderState st; private PMVMatrix pmvMatrix; private GLUniformData pmvMatrixUniform; @@ -62,19 +63,31 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("RedSquareES2.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("RedSquareES2.endTileRendering: "+tr); + } + public void setAspect(float aspect) { this.aspect = aspect; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } + @Override public void init(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.init: tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = glad.getGL().getGL2ES2(); @@ -138,6 +151,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende System.err.println(Thread.currentThread()+" RedSquareES2.init FIN"); } + @Override public void display(GLAutoDrawable glad) { long t1 = System.currentTimeMillis(); @@ -174,10 +188,27 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende st.useProgram(gl, false); } + @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { - System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(glad.getHandle())+", tileRendererInUse "+tileRendererInUse); - // Thread.dumpStack(); final GL2ES2 gl = glad.getGL().getGL2ES2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", tileRendererInUse "+tileRendererInUse); + // Thread.dumpStack(); if( !gl.hasGLSL() ) { return; } @@ -187,24 +218,6 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - if(-1 != swapInterval) { - gl.setSwapInterval(swapInterval); - } - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } // compute projection parameters 'normal' perspective final float fovy=45f; final float aspect2 = ( (float) imageWidth / (float) imageHeight ) / aspect; @@ -233,6 +246,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN"); } + @Override public void dispose(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.dispose: tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = glad.getGL().getGL2ES2(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 110dfb779..74089c2fd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -26,7 +26,7 @@ import com.jogamp.opengl.util.TileRendererBase; * * This version is equal to Brian Paul's version 1.2 1999/10/21 */ -public class Gears implements GLEventListener, TileRendererBase.TileRendererNotify { +public class Gears implements GLEventListener, TileRendererBase.TileRendererListener { private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; private int gear1=0, gear2=0, gear3=0; private float angle = 0.0f; @@ -49,15 +49,25 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("Gears.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("Gears.endTileRendering: "+tr); + } public void setDoRotation(boolean rotate) { doRotate = rotate; } public void setVerbose(boolean v) { verbose = v; } @@ -83,6 +93,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti */ public int getGear3() { return gear3; } + @Override public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); @@ -154,14 +165,31 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti gl.glEnable(GL2.GL_NORMALIZE); } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - GL2 gl = drawable.getGL().getGL2(); - this.reshape(gl, x, y, width, height); + @Override + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + final GL2 gl = glad.getGL().getGL2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); } - + public void reshape(GL2 gl, int x, int y, int width, int height) { + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2 gl = tr.getAttachedDrawable().getGL().getGL2(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); - System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); if( msaa ) { gl.glEnable(GL.GL_MULTISAMPLE); @@ -171,23 +199,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti gl.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - gl.setSwapInterval(swapInterval); - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } - // compute projection parameters 'normal' float left, right, bottom, top; if( imageHeight > imageWidth ) { @@ -228,6 +239,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti } } + @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" Gears.dispose: tileRendererInUse "+tileRendererInUse); try { @@ -241,6 +253,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti setGears(0, 0, 0); } + @Override public void display(GLAutoDrawable drawable) { // Get the GL corresponding to the drawable we are animating GL2 gl = drawable.getGL().getGL2(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java index 09817a27f..d539b5e55 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java @@ -107,7 +107,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { // Initialize the tile rendering library final RandomTileRenderer renderer = new RandomTileRenderer(); - renderer.attachToAutoDrawable(glad); + renderer.attachAutoDrawable(glad); renderer.setImageSize(imageWidth, imageHeight); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; @@ -146,7 +146,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { } } - renderer.detachFromAutoDrawable(); + renderer.detachAutoDrawable(); // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java index 16f11d85b..7d3f1f622 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java @@ -196,7 +196,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { } catch (IOException e) { e.printStackTrace(); } - renderer.detachFromAutoDrawable(); + renderer.detachAutoDrawable(); System.err.println("XXX post-display detached: "+renderer); drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); glad.getGLEventListener(0).reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); @@ -224,7 +224,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { signalTileRenderer = false; // tile rendering ! System.err.println("XXX START TILE RENDERING"); - renderer.attachToAutoDrawable(glad); + renderer.attachAutoDrawable(glad); } Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java index 26ac34d5a..f0819a43d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java @@ -188,7 +188,7 @@ public class TestTiledRendering2NEWT extends UITestCase { final TileRenderer renderer = new TileRenderer(); renderer.setImageSize(imageWidth, imageHeight); renderer.setTileSize(glad.getWidth(), glad.getHeight(), 0); - renderer.attachToAutoDrawable(glad); + renderer.attachAutoDrawable(glad); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; final boolean[] flipVertically = { false }; @@ -219,7 +219,7 @@ public class TestTiledRendering2NEWT extends UITestCase { renderer.display(); } while ( !renderer.eot() ); - renderer.detachFromAutoDrawable(); + renderer.detachAutoDrawable(); // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! -- cgit v1.2.3