diff options
author | Sven Gothel <[email protected]> | 2013-09-05 12:47:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-09-05 12:47:15 +0200 |
commit | 3f2e0d3a9a6cab80936851c44f61107a2993ddfe (patch) | |
tree | c2b0f7203044ea245981777ab40f397174a9ec4d /src/test/com/jogamp/opengl | |
parent | 7ee9b87bdb025f98651c2685d416029a17fc3937 (diff) |
TileRendererBase: Add interface TileRendererNotify, to notify implementing GLEventListener about attached/detached TileRenderer
.. since GLEventListener's reshape(..) method must query certain tile renderer attributes (tile pos and image size),
they have to be aware of the TileRendererBase.
To simplify such awareness and hence automate this attachement and passing over the tile renderer reference,
they should implement this new interface.
Gears example implements the new interface,
which caches the TR reference and pauses rotation.
Diffstat (limited to 'src/test/com/jogamp/opengl')
5 files changed, 13 insertions, 18 deletions
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 0c84fac39..22fb72aec 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 @@ -25,8 +25,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 { +public class Gears implements GLEventListener, TileRendererBase.TileRendererNotify { 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; @@ -47,11 +46,18 @@ public class Gears implements GLEventListener { this.swapInterval = 1; } - public void setTileRenderer(TileRendererBase tileRenderer) { - tileRendererInUse = tileRenderer; + private boolean doRotateBeforePrinting; + public void addTileRendererNotify(TileRendererBase tr) { + tileRendererInUse = tr; + doRotateBeforePrinting = doRotate; + setDoRotation(false); + } + public void removeTileRendererNotify(TileRendererBase tr) { + tileRendererInUse = null; + setDoRotation(doRotateBeforePrinting); } - public void setDoRotation(boolean rotate) { this.doRotate = rotate; } + public void setDoRotation(boolean rotate) { doRotate = rotate; } public void setGears(int g1, int g2, int g3) { gear1 = g1; 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 866a8a753..ca9bf9a9c 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 @@ -85,7 +85,6 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); final Gears gears = new Gears(); - gears.setDoRotation(false); glad.addGLEventListener( gears ); // Fix the image size for now @@ -97,7 +96,6 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { // Initialize the tile rendering library final RandomTileRenderer renderer = new RandomTileRenderer(); - gears.setTileRenderer(renderer); renderer.attachToAutoDrawable(glad); renderer.setImageSize(imageWidth, imageHeight); @@ -138,7 +136,6 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { } renderer.detachFromAutoDrawable(); - gears.setTileRenderer(null); // 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 28ff19bad..2b7e727b8 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 @@ -129,7 +129,6 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { @Override public void init(GLAutoDrawable drawable) { - gears.setDoRotation(false); final GL gl = drawable.getGL(); GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); @@ -189,12 +188,10 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { } catch (IOException e) { e.printStackTrace(); } - gears.setTileRenderer(null); renderer.detachFromAutoDrawable(); 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()); - gears.setDoRotation(true); } } @Override @@ -219,7 +216,6 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { signalTileRenderer = false; // tile rendering ! System.err.println("XXX START TILE RENDERING"); - gears.setTileRenderer(renderer); renderer.attachToAutoDrawable(glad); } Thread.sleep(100); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java index c80a0cadd..62bdf6d64 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java @@ -131,17 +131,16 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { flipVertically[0] = false; final Gears gears = new Gears(); - gears.setDoRotation(false); gears.init(gl); - gears.setTileRenderer(renderer); + gears.addTileRendererNotify(renderer); do { renderer.beginTile(dc.glc.getGL().getGL2ES3()); gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT)); gears.display(gl); renderer.endTile(dc.glc.getGL().getGL2ES3()); } while ( !renderer.eot() ); - gears.setTileRenderer(null); + gears.removeTileRendererNotify(renderer); destroyDrawableContext(dc); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2NEWT.java index 72917bc7f..fb26eeb24 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2NEWT.java @@ -85,7 +85,6 @@ public class TestTiledRendering2GL2NEWT extends UITestCase { final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); final Gears gears = new Gears(); - gears.setDoRotation(false); glad.addGLEventListener( gears ); // Fix the image size for now @@ -97,7 +96,6 @@ public class TestTiledRendering2GL2NEWT extends UITestCase { // Initialize the tile rendering library final TileRenderer renderer = new TileRenderer(); - gears.setTileRenderer(renderer); renderer.attachToAutoDrawable(glad); renderer.setImageSize(imageWidth, imageHeight); @@ -131,7 +129,6 @@ public class TestTiledRendering2GL2NEWT extends UITestCase { } while ( !renderer.eot() ); renderer.detachFromAutoDrawable(); - gears.setTileRenderer(null); // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! |