aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java93
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java4
3 files changed, 94 insertions, 26 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 74089c2fd..031d6a1c1 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
@@ -97,11 +97,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
- System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse);
- System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
- System.err.println("INIT GL IS: " + gl.getClass().getName());
- System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
-
init(gl);
final Object upstreamWidget = drawable.getUpstreamWidget();
@@ -122,6 +117,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };
+ System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse);
+ if(verbose) {
+ System.err.println("GearsES2 init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + gl.getContext().getGLDrawable().getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
gl.glEnable(GL2.GL_CULL_FACE);
gl.glEnable(GL2.GL_LIGHTING);
@@ -171,11 +174,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
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);
+ reshape(gl, x, y, width, height, width, height);
}
@Override
@@ -184,10 +183,10 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
int imageWidth, int imageHeight) {
final GL2 gl = tr.getAttachedDrawable().getGL().getGL2();
gl.setSwapInterval(0);
- reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
+ reshape(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
}
- void reshapeImpl(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) {
+ public void reshape(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(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);
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 c38140ce0..e0fabc3cc 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
@@ -46,7 +46,6 @@ import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -67,11 +66,6 @@ import org.junit.runners.MethodSorters;
public class TestTiledRendering1GL2NEWT extends UITestCase {
static long duration = 500; // ms
- @Test
- public void test01() throws IOException {
- doTest();
- }
-
static class DrawableContext {
DrawableContext(GLDrawable d, GLContext glc) {
this.d = d;
@@ -102,7 +96,8 @@ public class TestTiledRendering1GL2NEWT extends UITestCase {
}
}
- void doTest() throws GLException, IOException {
+ @Test
+ public void test01() throws IOException {
GLProfile glp = GLProfile.getMaxFixedFunc(true);
GLCapabilities caps = new GLCapabilities(glp);
caps.setOnscreen(false);
@@ -132,15 +127,19 @@ public class TestTiledRendering1GL2NEWT extends UITestCase {
flipVertically[0] = false;
final Gears gears = new Gears();
+ gears.setVerbose(false);
gears.init(gl);
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));
+ while( !renderer.eot() ) {
+ renderer.beginTile(gl);
+ gears.reshape(gl,
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS),
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT),
+ renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT));
gears.display(gl);
- renderer.endTile(dc.glc.getGL().getGL2ES3());
- } while ( !renderer.eot() );
+ renderer.endTile(gl);
+ }
gears.removeTileRendererNotify(renderer);
destroyDrawableContext(dc);
@@ -160,6 +159,76 @@ public class TestTiledRendering1GL2NEWT extends UITestCase {
TextureIO.write(textureData, file);
}
+ @Test
+ public void test02_EOT_01() throws IOException {
+ GLProfile glp = GLProfile.getMaxFixedFunc(true);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+
+ final int maxTileSize = 256;
+ DrawableContext dc = createDrawableAndCurrentCtx(caps, maxTileSize, maxTileSize);
+ final GL2 gl = dc.glc.getGL().getGL2();
+
+ // Fix the image size for now
+ final int imageWidth = dc.d.getWidth() * 6;
+ final int imageHeight = dc.d.getHeight() * 4;
+
+ // Initialize the tile rendering library
+ final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer();
+ renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0);
+
+ IllegalStateException ise = null;
+ try {
+ renderer.beginTile(gl); // Image size has not been set
+ } catch (IllegalStateException _ise) {
+ ise = _ise;
+ System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage());
+ }
+ Assert.assertNotNull("TileRenderer.beginTile: Image-size exception missing", ise);
+
+ renderer.setImageSize(imageWidth, imageHeight);
+
+ renderer.clipImageSize(0, 0);
+ try {
+ renderer.beginTile(gl); // EOT reached (1)
+ } catch (IllegalStateException _ise) {
+ ise = _ise;
+ System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage());
+ }
+ Assert.assertNotNull("TileRenderer.beginTile: EOT (1) exception missing", ise);
+
+ renderer.clipImageSize(imageWidth, imageHeight); // back to full size
+
+ final Gears gears = new Gears();
+ gears.setVerbose(false);
+ gears.init(gl);
+
+ gears.addTileRendererNotify(renderer);
+ int numTiles = 0;
+ while( !renderer.eot() ) {
+ renderer.beginTile(gl);
+ gears.reshape(gl,
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS),
+ renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT),
+ renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT));
+ gears.display(gl);
+ renderer.endTile(gl);
+ numTiles++;
+ }
+ try {
+ renderer.beginTile(gl); // EOT reached (2)
+ } catch (IllegalStateException _ise) {
+ ise = _ise;
+ System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage());
+ }
+ Assert.assertNotNull("TileRenderer.beginTile: EOT (2) exception missing", ise);
+ gears.removeTileRendererNotify(renderer);
+
+ Assert.assertTrue("TileRenderer not rendered more than one tile but "+numTiles, numTiles > 1);
+
+ destroyDrawableContext(dc);
+ }
+
public static void main(String args[]) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
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 f0819a43d..74909dc8c 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
@@ -215,9 +215,9 @@ public class TestTiledRendering2NEWT extends UITestCase {
};
renderer.setGLEventListener(preTileGLEL, null);
- do {
+ while ( !renderer.eot() ) {
renderer.display();
- } while ( !renderer.eot() );
+ }
renderer.detachAutoDrawable();