aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-04-10 06:52:16 +0200
committerSven Gothel <[email protected]>2014-04-10 06:52:16 +0200
commitb222d19e5f45fc3683b58dd788262597a1e14635 (patch)
tree900afce8d30e94fc4543e2a856fc86679bbdd1f1 /src/test/com/jogamp/opengl
parent45395696c252c215a8a22d05e5da7e98c662d07e (diff)
Reduce jar-size / cleanup: Replace 1 kB test-ntsc01-57x32.png w/ 400kB test-ntsc01-28x16.png asset ; Generalize TextureSequenceDemo01 -> SingleTextureSeqFrame ; Unit tests use test-data, not assets.
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java)12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java28
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java22
5 files changed, 52 insertions, 50 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
index dac917ee2..64e4472c0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
@@ -8,6 +8,7 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.test.junit.jogl.util.texture.PNGTstFiles;
import com.jogamp.opengl.util.gl2.GLUT;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureIO;
@@ -21,8 +22,8 @@ public class Teapot implements GLEventListener {
private GLUT glut;
/* glTexGen stuff: */
- private float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
-
+ private final float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+
private Texture tex = null;
@Override
@@ -33,7 +34,7 @@ public class Teapot implements GLEventListener {
gl.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
try {
- URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-57x32.png", this.getClass().getClassLoader());
+ URLConnection urlConn = IOUtil.getResource(PNGTstFiles.class, "test-ntscP_3-01-160x90.png");
tex = TextureIO.newTexture(gl, TextureIO.newTextureData(gl.getGLProfile(), urlConn.getInputStream(), false, TextureIO.PNG));
} catch (Exception e) {
e.printStackTrace();
@@ -55,7 +56,7 @@ public class Teapot implements GLEventListener {
// GL.GL_RGB, GL.GL_UNSIGNED_BYTE, stripeImageBuf);
gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
-
+
// gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
// gl.glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, sgenparams, 0);
@@ -77,14 +78,14 @@ public class Teapot implements GLEventListener {
float angleZ = 0.0f;
float rotDir = 1.0f;
public float rotIncr = 0.4f;
-
+
@Override
public void display(GLAutoDrawable gLDrawable) {
final GL2 gl = gLDrawable.getGL().getGL2();
tex.bind(gl);
gl.glEnable(GL2.GL_TEXTURE_2D);
-
+
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
gl.glRotatef(angleZ, 0.0f, 1.0f, 0.0f);
@@ -97,7 +98,7 @@ public class Teapot implements GLEventListener {
} else if (angleZ <= 0.0f ) {
rotDir = +1.0f;
}
- angleZ += rotIncr * rotDir;
+ angleZ += rotIncr * rotDir;
}
@Override
@@ -108,11 +109,11 @@ public class Teapot implements GLEventListener {
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
if (w <= h) {
- gl.glOrtho(-3.5, 3.5, -3.5 * (float) h / (float) w,
- 3.5 * (float) h / (float) w, -3.5, 3.5);
+ gl.glOrtho(-3.5, 3.5, -3.5 * h / w,
+ 3.5 * h / w, -3.5, 3.5);
} else {
- gl.glOrtho(-3.5 * (float) w / (float) h,
- 3.5 * (float) w / (float) h, -3.5, 3.5, -3.5, 3.5);
+ gl.glOrtho(-3.5 * w / h,
+ 3.5 * w / h, -3.5, 3.5, -3.5, 3.5);
}
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java
index d776021ba..81fa5ded3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -33,6 +33,7 @@ import java.net.URLConnection;
import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.test.junit.jogl.util.texture.PNGTstFiles;
import com.jogamp.opengl.util.ImmModeSink;
import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
@@ -54,8 +55,8 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra
private boolean verboseFFPEmu = false;
private boolean traceFFPEmu = false;
private boolean forceFFPEmu = false;
- private ImmModeSink ims;
- private GLU glu = new GLU();
+ private final ImmModeSink ims;
+ private final GLU glu = new GLU();
private TextureData textureData;
private Texture texture;
boolean keepTextureBound;
@@ -81,7 +82,7 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra
public Texture getTexture( ) {
return this.texture;
}
-
+
@Override
public void init(GLAutoDrawable drawable) {
GL _gl = drawable.getGL();
@@ -95,7 +96,7 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra
}
GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
- URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-57x32.png", this.getClass().getClassLoader());
+ URLConnection testTextureUrlConn = IOUtil.getResource(PNGTstFiles.class, "test-ntscP_3-01-160x90.png");
try {
InputStream testTextureStream = testTextureUrlConn.getInputStream();
textureData = TextureIO.newTextureData(gl.getGLProfile(), testTextureStream , false /* mipmap */, TextureIO.PNG);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java
index 7034f2c67..aef48d82c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java
@@ -1,4 +1,4 @@
-package com.jogamp.opengl.test.junit.jogl.demos;
+package com.jogamp.opengl.test.junit.jogl.util.texture;
import java.net.URLConnection;
@@ -12,24 +12,24 @@ import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
import com.jogamp.opengl.util.texture.TextureSequence;
-public class TextureSequenceDemo01 implements TextureSequence {
+public class SingleTextureSeqFrame implements TextureSequence {
TextureSequence.TextureFrame frame = null;
int textureUnit = 0;
protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST };
protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE };
final boolean useBuildInTexLookup;
- public TextureSequenceDemo01(boolean useBuildInTexLookup) {
+ public SingleTextureSeqFrame(boolean useBuildInTexLookup) {
this.useBuildInTexLookup = useBuildInTexLookup;
}
- public void initGLResources(GL gl) throws GLException {
+ public void initGLResources(GL gl, Class<?> context, String imageResourcePath, String imageSuffix) throws GLException {
if(null == frame) {
TextureData texData = null;
try {
- URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-57x32.png", this.getClass().getClassLoader());
+ URLConnection urlConn = IOUtil.getResource(context, imageResourcePath);
if(null != urlConn) {
- texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG);
+ texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, imageSuffix);
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java
index 2b3ead5b9..9dc17dce1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java
@@ -15,12 +15,12 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
-import com.jogamp.opengl.test.junit.jogl.demos.TextureSequenceDemo01;
import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.texture.TextureIO;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestTextureSequence01AWT extends UITestCase {
@@ -31,7 +31,7 @@ public class TestTextureSequence01AWT extends UITestCase {
static long duration = 500; // ms
static GLProfile glp;
static GLCapabilities caps;
-
+
@BeforeClass
public static void initClass() {
glp = GLProfile.getGL2ES2();
@@ -45,19 +45,19 @@ public class TestTextureSequence01AWT extends UITestCase {
final Frame frame = new Frame("TestTextureSequence01AWT");
Assert.assertNotNull(frame);
frame.add(glc);
-
- final TextureSequenceDemo01 texSource = new TextureSequenceDemo01(useBuildInTexLookup);
+
+ final SingleTextureSeqFrame texSource = new SingleTextureSeqFrame(useBuildInTexLookup);
glc.addGLEventListener(new GLEventListener() {
@Override
public void init(GLAutoDrawable drawable) {
- texSource.initGLResources(drawable.getGL());
+ texSource.initGLResources(drawable.getGL(), TestTextureSequence01AWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG);
}
@Override
public void dispose(GLAutoDrawable drawable) { }
@Override
public void display(GLAutoDrawable drawable) { }
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
glc.addGLEventListener(new TextureSequenceCubeES2(texSource, false, -2.3f, 0f, 0f));
final Animator animator = new Animator(glc);
@@ -74,13 +74,13 @@ public class TestTextureSequence01AWT extends UITestCase {
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
animator.start();
-
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
-
+
animator.stop();
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
@@ -94,14 +94,14 @@ public class TestTextureSequence01AWT extends UITestCase {
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
}
-
+
@Test
public void test1() throws InterruptedException {
- testImpl();
+ testImpl();
}
-
+
public static void main(String[] args) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -117,7 +117,7 @@ public class TestTextureSequence01AWT extends UITestCase {
useBuildInTexLookup = true;
}
}
- org.junit.runner.JUnitCore.main(TestTextureSequence01AWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestTextureSequence01AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java
index 5145e104f..c46e334bd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java
@@ -12,12 +12,12 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.test.junit.jogl.demos.TextureSequenceDemo01;
import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.texture.TextureIO;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestTextureSequence01NEWT extends UITestCase {
@@ -28,7 +28,7 @@ public class TestTextureSequence01NEWT extends UITestCase {
static long duration = 500; // ms
static GLProfile glp;
static GLCapabilities caps;
-
+
@BeforeClass
public static void initClass() {
glp = GLProfile.getGL2ES2();
@@ -42,18 +42,18 @@ public class TestTextureSequence01NEWT extends UITestCase {
window.setTitle("TestTextureSequence01NEWT");
// Size OpenGL to Video Surface
window.setSize(width, height);
- final TextureSequenceDemo01 texSource = new TextureSequenceDemo01(useBuildInTexLookup);
+ final SingleTextureSeqFrame texSource = new SingleTextureSeqFrame(useBuildInTexLookup);
window.addGLEventListener(new GLEventListener() {
@Override
public void init(GLAutoDrawable drawable) {
- texSource.initGLResources(drawable.getGL());
+ texSource.initGLResources(drawable.getGL(), TestTextureSequence01NEWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG);
}
@Override
public void dispose(GLAutoDrawable drawable) { }
@Override
public void display(GLAutoDrawable drawable) { }
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
window.addGLEventListener(new TextureSequenceCubeES2(texSource, false, -2.3f, 0f, 0f));
final Animator animator = new Animator(window);
@@ -63,22 +63,22 @@ public class TestTextureSequence01NEWT extends UITestCase {
window.addWindowListener(quitAdapter);
animator.start();
window.setVisible(true);
-
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
-
+
animator.stop();
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
window.destroy();
}
-
+
@Test
public void test1() throws InterruptedException {
- testImpl();
+ testImpl();
}
-
+
public static void main(String[] args) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -94,7 +94,7 @@ public class TestTextureSequence01NEWT extends UITestCase {
useBuildInTexLookup = true;
}
}
- org.junit.runner.JUnitCore.main(TestTextureSequence01NEWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestTextureSequence01NEWT.class.getName());
}
}