summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2012-06-18 03:39:39 +0200
committerSven Gothel <sgothel@jausoft.com>2012-06-18 03:39:39 +0200
commite8078eb70f6f82613d730ae5b8f837ccb46b81fb (patch)
tree87f6b7fe1d47e3b2b85d2983281eb942afc4cccc /src/test/com
parent7f341c7bc0d0f5770191bb58f2c0053c3453bc8a (diff)
Texture Unit Tests: AWT/NEWT GL2/ES2 PNGJ/AWT-PNG-Loading and Rendering (TestPNGTextureFromFile[AWT/NEWT])
Properly test combinations of TextureIO usage w/ - NEWT / AWT usage - GL2 / ES2 usage - PNG implementations: PNGJ (internal) and AWT - adding screenshots of result for later analysis Misc: - IOUtil.getResource(..) usage CLASS.class.getClassLoader() -> this.getClass().getClassLoader()
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java249
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TextureGL2ListenerDraw1.java)26
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java149
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java238
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java173
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java2
13 files changed, 755 insertions, 182 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java
new file mode 100644
index 000000000..b9ac9faad
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * 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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * 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.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos;
+
+import com.jogamp.opengl.util.texture.Texture;
+
+public interface TextureDraw01Accessor {
+ public Texture getTexture();
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
index a1d4b4466..6fd47e63f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
@@ -6,8 +6,6 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.opengl.util.av.NullGLMediaPlayer;
-
import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureData;
@@ -29,7 +27,7 @@ public class TextureSequenceDemo01 implements TextureSequence {
if(null == frame) {
TextureData texData = null;
try {
- URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader());
+ URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
if(null != urlConn) {
texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
new file mode 100644
index 000000000..6e701658c
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
@@ -0,0 +1,249 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * 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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * 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.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos.es2;
+
+import java.nio.FloatBuffer;
+
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLUniformData;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+
+public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01Accessor {
+ TextureData textureData;
+ Texture texture;
+
+ ShaderState st;
+ PMVMatrix pmvMatrix;
+ GLUniformData pmvMatrixUniform;
+ GLArrayDataServer interleavedVBO;
+
+
+ public TextureDraw01ES2Listener(TextureData td) {
+ this.textureData = td;
+ }
+
+ static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
+ static final String gl2_prelude = "#version 110\n";
+ static final String shaderBasename = "texture01_xxx";
+
+ private void initShader(GL2ES2 gl, boolean use_program) {
+ // Create & Compile the shader objects
+ ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+
+ // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
+ int rsFpPos;
+ if(gl.isGLES2()) {
+ rsVp.insertShaderSource(0, 0, es2_prelude[0]);
+ rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]);
+ } else {
+ rsVp.insertShaderSource(0, 0, gl2_prelude);
+ rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude);
+ }
+ if(gl.isGLES2()) {
+ rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
+ }
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(rsVp);
+ sp.add(rsFp);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ // Let's manage all our states using ShaderState.
+ st = new ShaderState();
+ st.attachShaderProgram(gl, sp, use_program);
+ }
+
+ public void init(GLAutoDrawable glad) {
+ if(null!=textureData) {
+ this.texture = TextureIO.newTexture(glad.getGL(), textureData);
+ }
+ GL2ES2 gl = glad.getGL().getGL2ES2();
+
+ initShader(gl, true);
+
+ // setup mgl_PMVMatrix
+ pmvMatrix = new PMVMatrix();
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+
+ st.ownUniform(pmvMatrixUniform);
+ if(!st.uniform(gl, pmvMatrixUniform)) {
+ throw new GLException("Error setting PMVMatrix in shader: "+st);
+ }
+ if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) {
+ throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
+ }
+
+ // fetch the flipped texture coordinates
+ texture.getImageTexCoords().getST_LB_RB_LT_RT(s_quadTexCoords, 0, 1f, 1f);
+
+ interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
+ {
+ interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+ //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
+
+ FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
+
+ for(int i=0; i<4; i++) {
+ ib.put(s_quadVertices, i*3, 3);
+ ib.put(s_quadColors, i*4, 4);
+ //ib.put(s_cubeNormals, i*3, 3);
+ ib.put(s_quadTexCoords, i*2, 2);
+ }
+ }
+ interleavedVBO.seal(gl, true);
+ interleavedVBO.enableBuffer(gl, false);
+ st.ownAttribute(interleavedVBO, true);
+
+ // OpenGL Render Settings
+ gl.glClearColor(0, 0, 0, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+ st.useProgram(gl, false);
+ }
+
+ public Texture getTexture( ) {
+ return this.texture;
+ }
+
+ /**
+ public void setTextureData(GL gl, TextureData textureData ) {
+ if(null!=texture) {
+ texture.disable(gl);
+ texture.destroy(gl);
+ }
+ if(null!=this.textureData) {
+ this.textureData.destroy();
+ }
+ this.textureData = textureData;
+ this.texture = TextureIO.newTexture(this.textureData);
+
+ // fix VBO !
+ } */
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glViewport(0, 0, width, height);
+
+ // Clear background to white
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f);
+
+ if(null != st) {
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ st.useProgram(gl, true);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+ }
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ if(null!=texture) {
+ texture.disable(gl);
+ texture.destroy(gl);
+ }
+ if(null!=textureData) {
+ textureData.destroy();
+ }
+
+ pmvMatrixUniform = null;
+ pmvMatrix.destroy();
+ pmvMatrix=null;
+ st.destroy(gl);
+ st=null;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ st.useProgram(gl, true);
+ interleavedVBO.enableBuffer(gl, true);
+ gl.glActiveTexture(GL.GL_TEXTURE0);
+ texture.enable(gl);
+ texture.bind(gl);
+
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+
+ texture.disable(gl);
+ interleavedVBO.enableBuffer(gl, false);
+ st.useProgram(gl, false);
+ }
+
+ private static final float[] s_quadVertices = {
+ -1f, -1f, 0f, // LB
+ 1f, -1f, 0f, // RB
+ -1f, 1f, 0f, // LT
+ 1f, 1f, 0f // RT
+ };
+ private static final float[] s_quadColors = {
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f };
+ private static final float[] s_quadTexCoords = {
+ 0f, 0f, // LB
+ 1f, 0f, // RB
+ 0f, 1f, // LT
+ 1f, 1f // RT
+ };
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
index c2fbc65af..b04bd07c1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
@@ -146,9 +146,9 @@ public class TextureSequenceCubeES2 implements GLEventListener {
private void initShader(GL2ES2 gl) {
// Create & Compile the shader objects
- ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextureSequenceCubeES2.class,
+ ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
- ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextureSequenceCubeES2.class,
+ ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
// Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
@@ -205,7 +205,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
pmvMatrix = new PMVMatrix();
reshapePMV(drawable.getWidth(), drawable.getHeight());
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
@@ -214,6 +214,8 @@ public class TextureSequenceCubeES2 implements GLEventListener {
}
+ // calculate centered tex coords w/ aspect ratio
+ float[] fixedCubeTexCoords = new float[s_cubeTexCoords.length];
{
final float aspect = tex.getAspectRatio();
final TextureCoords tc = tex.getImageTexCoords();
@@ -228,17 +230,16 @@ public class TextureSequenceCubeES2 implements GLEventListener {
final float tx = s_cubeTexCoords[i+0];
final float ty = s_cubeTexCoords[i+1];
if(tx!=0) {
- s_cubeTexCoords[i+0] = tc_x1 * ss;
+ fixedCubeTexCoords[i+0] = tc_x1 * ss;
}
if(ty==0 && !tex.getMustFlipVertically() || ty!=0 && tex.getMustFlipVertically()) {
- s_cubeTexCoords[i+1] = 0f + dy;
+ fixedCubeTexCoords[i+1] = 0f + dy;
} else {
- s_cubeTexCoords[i+1] = tc_y1 * ts + dy;
+ fixedCubeTexCoords[i+1] = tc_y1 * ts + dy;
}
}
}
-
-
+
interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*6*4, GL.GL_STATIC_DRAW);
{
interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
@@ -252,7 +253,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
ib.put(s_cubeVertices, i*3, 3);
ib.put(s_cubeColors, i*4, 4);
//ib.put(s_cubeNormals, i*3, 3);
- ib.put(s_cubeTexCoords, i*2, 2);
+ ib.put(fixedCubeTexCoords, i*2, 2);
}
}
interleavedVBO.seal(gl, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp
new file mode 100644
index 000000000..1a4254163
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp
@@ -0,0 +1,20 @@
+// Copyright 2012 JogAmp Community. All rights reserved.
+
+varying vec2 mgl_texCoord;
+varying vec4 frontColor;
+
+uniform sampler2D mgl_ActiveTexture;
+
+void main (void)
+{
+ vec4 texColor;
+ if(0.0 <= mgl_texCoord.t && mgl_texCoord.t<=1.0) {
+ texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
+ } else {
+ texColor = vec4(1, 1, 1, 1);
+ }
+
+ // mix frontColor with texture ..
+ gl_FragColor = vec4(frontColor*texColor);
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp
new file mode 100644
index 000000000..c521e3757
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp
@@ -0,0 +1,17 @@
+// Copyright 2012 JogAmp Community. All rights reserved.
+
+uniform mat4 mgl_PMVMatrix[2];
+// uniform mat4 mgl_STMatrix;
+attribute vec4 mgl_Vertex;
+attribute vec4 mgl_Color;
+attribute vec4 mgl_MultiTexCoord;
+varying vec4 frontColor;
+varying vec2 mgl_texCoord;
+
+void main(void)
+{
+ frontColor=mgl_Color;
+ // mgl_texCoord = (mgl_STMatrix * mgl_MultiTexCoord).st;
+ mgl_texCoord = mgl_MultiTexCoord.st;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TextureGL2ListenerDraw1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java
index cec151584..af30c265b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TextureGL2ListenerDraw1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java
@@ -26,8 +26,9 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.util.texture;
+package com.jogamp.opengl.test.junit.jogl.demos.gl2;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureData;
@@ -38,25 +39,25 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
-public class TextureGL2ListenerDraw1 implements GLEventListener {
+public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01Accessor {
private GLU glu = new GLU();
private TextureData textureData;
private Texture texture;
- public TextureGL2ListenerDraw1(TextureData td) {
+ public TextureDraw01GL2Listener(TextureData td) {
this.textureData = td;
}
public void init(GLAutoDrawable drawable) {
if(null!=textureData) {
- this.texture = TextureIO.newTexture(textureData);
+ this.texture = TextureIO.newTexture(drawable.getGL(), textureData);
}
}
- public void setTexture( Texture texture ) {
- this.texture = texture;
+ public Texture getTexture( ) {
+ return this.texture;
}
-
+
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL2 gl = drawable.getGL().getGL2();
gl.glMatrixMode(GL2ES1.GL_PROJECTION);
@@ -80,16 +81,7 @@ public class TextureGL2ListenerDraw1 implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
- // need a valid GL context for this ..
-
- /** OpenGL ..
- texture.updateSubImage(textureData, 0,
- 20, 20,
- 20, 20,
- 100, 100); */
-
-
- // Now draw one quad with the texture
+ // draw one quad with the texture
if(null!=texture) {
texture.enable(gl);
texture.bind(gl);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
index 5a0c18de7..c7e975ff6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
@@ -18,7 +18,7 @@ public class TestPNGImage01NEWT extends UITestCase {
final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png");
final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png");
final String url_s="jogl/util/data/av/test-ntsc01-160x90.png";
- URLConnection urlConn = IOUtil.getResource(url_s, PNGImage.class.getClassLoader());
+ URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader());
PNGImage image0 = PNGImage.read(urlConn.getInputStream());
System.err.println("PNGImage - Orig: "+image0);
image0.write(out1_f, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java
deleted file mode 100644
index a1e453fda..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * 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
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * 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.
- */
-
-package com.jogamp.opengl.test.junit.jogl.util.texture;
-
-
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.texture.TextureIO;
-import com.jogamp.opengl.util.Animator;
-
-import java.awt.Frame;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Assert;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Unit test for bug 417, which shows a GLException when reading a grayscale texture.
- * Couldn't duplicate the failure, so it must have been fixed unknowingly sometime
- * after the bug was submitted.
- * @author Wade Walker
- */
-public class TestGrayTextureFromFileAWTBug417 extends UITestCase {
- static GLProfile glp;
- static GLCapabilities caps;
- InputStream textureStream;
-
- @BeforeClass
- public static void initClass() {
- if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
- UITestCase.setTestSupported(false);
- return;
- }
- glp = GLProfile.getGL2GL3();
- Assert.assertNotNull(glp);
- caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- }
-
- @Before
- public void initTest() {
- textureStream = TestGrayTextureFromFileAWTBug417.class.getResourceAsStream( "grayscale_texture.png" );
- Assert.assertNotNull(textureStream);
- }
-
- @After
- public void cleanupTest() {
- textureStream=null;
- }
-
- @Test
- public void test1() throws InterruptedException {
- final GLCanvas glCanvas = new GLCanvas(caps);
- final Frame frame = new Frame("Texture Test");
- Assert.assertNotNull(frame);
- frame.add(glCanvas);
- frame.setSize( 256, 128 );
-
- // load texture from file inside current GL context to match the way
- // the bug submitter was doing it
- glCanvas.addGLEventListener(new TextureGL2ListenerDraw1( null ) {
- @Override
- public void init(GLAutoDrawable drawable) {
- try {
- setTexture( TextureIO.newTexture( textureStream, true, TextureIO.PNG ) );
- }
- catch(GLException glexception) {
- glexception.printStackTrace();
- Assume.assumeNoException(glexception);
- }
- catch(IOException ioexception) {
- ioexception.printStackTrace();
- Assume.assumeNoException(ioexception);
- }
- }
- });
-
- Animator animator = new Animator(glCanvas);
- frame.setVisible(true);
- animator.start();
-
- Thread.sleep(500); // 500 ms
-
- animator.stop();
- try {
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- frame.setVisible(false);
- frame.remove(glCanvas);
- frame.dispose();
- }});
- } catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestGrayTextureFromFileAWTBug417.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- tstname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
new file mode 100644
index 000000000..068732696
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
@@ -0,0 +1,238 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * 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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * 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.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.util.texture;
+
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
+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 javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.awt.GLCanvas;
+
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.texture.spi.TextureProvider;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLConnection;
+
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for bug 417, which shows a GLException when reading a grayscale texture.
+ * Couldn't duplicate the failure, so it must have been fixed unknowingly sometime
+ * after the bug was submitted.
+ * @author Wade Walker, et.al.
+ */
+public class TestPNGTextureFromFileAWT extends UITestCase {
+ static boolean showFPS = false;
+ static long duration = 100; // ms
+ InputStream grayTextureStream;
+ InputStream testTextureStream;
+
+ @BeforeClass
+ public static void initClass() {
+ }
+
+ @Before
+ public void initTest() throws IOException {
+ grayTextureStream = TestPNGTextureFromFileAWT.class.getResourceAsStream( "grayscale_texture.png" );
+ Assert.assertNotNull(grayTextureStream);
+ URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
+ Assert.assertNotNull(testTextureUrlConn);
+ testTextureStream = testTextureUrlConn.getInputStream();
+ Assert.assertNotNull(testTextureStream);
+ }
+
+ @After
+ public void cleanupTest() {
+ grayTextureStream = null;
+ testTextureStream = null;
+ }
+
+ protected void snapshot(GLAutoDrawable drawable, String filename) {
+ GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
+ if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP)
+ throws InterruptedException, IOException
+ {
+ GLProfile glp;
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ glp = GLProfile.getGL2GL3();
+ } else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.getGL2ES2();
+ } else {
+ System.err.println(getSimpleTestName(".")+": GLProfile n/a, useFFP: "+useFFP);
+ return;
+ }
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final TextureData texData;
+ if(useAWTIIOP) {
+ final TextureProvider texProvider = new com.jogamp.opengl.util.texture.spi.awt.IIOTextureProvider();
+ texData = texProvider.newTextureData(glp, istream, 0 /* internalFormat */, 0 /* pixelFormat */, false /* mipmap */, TextureIO.PNG);
+ } else {
+ texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG);
+ }
+ System.err.println("TextureData: "+texData);
+
+ final GLCanvas glc = new GLCanvas(caps);
+ Dimension glc_sz = new Dimension(texData.getWidth(), texData.getHeight());
+ glc.setMinimumSize(glc_sz);
+ glc.setPreferredSize(glc_sz);
+ final Frame frame = new Frame("TestPNGTextureGL2FromFileAWT");
+ Assert.assertNotNull(frame);
+ frame.add(glc);
+
+ // load texture from file inside current GL context to match the way
+ // the bug submitter was doing it
+ final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ;
+ glc.addGLEventListener(gle);
+ glc.addGLEventListener(new GLEventListener() {
+ boolean shot = false;
+
+ @Override public void init(GLAutoDrawable drawable) {}
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ // 1 snapshot
+ if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) {
+ shot = true;
+ snapshot(drawable, getSimpleTestName(".")+".png");
+ }
+ }
+
+ @Override public void dispose(GLAutoDrawable drawable) { }
+ @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+
+ Animator animator = new Animator(glc);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc);
+ new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc);
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ animator.start();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.remove(glc);
+ frame.dispose();
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ @Test
+ public void testGrayAWTILoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, grayTextureStream, true);
+ }
+ @Test
+ public void testGrayAWTILoaderES2() throws InterruptedException, IOException {
+ testImpl(false, grayTextureStream, true);
+ }
+
+ @Test
+ public void testGrayPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, grayTextureStream, false);
+ }
+ @Test
+ public void testGrayPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, grayTextureStream, false);
+ }
+
+ @Test
+ public void testTestAWTILoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, testTextureStream, true);
+ }
+ @Test
+ public void testTestAWTILoaderES2() throws InterruptedException, IOException {
+ testImpl(false, testTextureStream, true);
+ }
+
+ @Test
+ public void testTestPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, testTextureStream, false);
+ }
+ @Test
+ public void testTestPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, testTextureStream, false);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestPNGTextureFromFileAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
new file mode 100644
index 000000000..d973dea2d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
@@ -0,0 +1,173 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * 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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * 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.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.util.texture;
+
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
+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 javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLCapabilities;
+
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLConnection;
+
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestPNGTextureFromFileNEWT extends UITestCase {
+ static boolean showFPS = false;
+ static long duration = 100; // ms
+ InputStream grayTextureStream;
+ InputStream testTextureStream;
+
+ @Before
+ public void initTest() throws IOException {
+ grayTextureStream = TestPNGTextureFromFileNEWT.class.getResourceAsStream( "grayscale_texture.png" );
+ Assert.assertNotNull(grayTextureStream);
+ URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
+ Assert.assertNotNull(testTextureUrlConn);
+ testTextureStream = testTextureUrlConn.getInputStream();
+ Assert.assertNotNull(testTextureStream);
+ }
+
+ @After
+ public void cleanupTest() {
+ grayTextureStream = null;
+ testTextureStream = null;
+ }
+
+ protected void snapshot(GLAutoDrawable drawable, String filename) {
+ GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
+ if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException {
+ GLProfile glp;
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ glp = GLProfile.getGL2GL3();
+ } else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.getGL2ES2();
+ } else {
+ System.err.println(getSimpleTestName(".")+": GLProfile n/a, useFFP: "+useFFP);
+ return;
+ }
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG);
+ System.err.println("TextureData: "+texData);
+
+ final GLWindow glad = GLWindow.create(caps);
+ glad.setTitle("TestPNGTextureGL2FromFileNEWT");
+ // Size OpenGL to Video Surface
+ glad.setSize(texData.getWidth(), texData.getHeight());
+
+ // load texture from file inside current GL context to match the way
+ // the bug submitter was doing it
+ final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ;
+ glad.addGLEventListener(gle);
+ glad.addGLEventListener(new GLEventListener() {
+ boolean shot = false;
+
+ @Override public void init(GLAutoDrawable drawable) {}
+
+ public void display(GLAutoDrawable drawable) {
+ // 1 snapshot
+ if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) {
+ shot = true;
+ snapshot(drawable, getSimpleTestName(".")+".png");
+ }
+ }
+
+ @Override public void dispose(GLAutoDrawable drawable) { }
+ @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+
+ Animator animator = new Animator(glad);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ glad.addKeyListener(quitAdapter);
+ glad.addWindowListener(quitAdapter);
+ glad.setVisible(true);
+ animator.start();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glad.destroy();
+ }
+
+ @Test
+ public void testGrayPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, grayTextureStream);
+ }
+ @Test
+ public void testGrayPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, grayTextureStream);
+ }
+
+ @Test
+ public void testTestPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, testTextureStream);
+ }
+ @Test
+ public void testTestPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, testTextureStream);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestPNGTextureFromFileNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java
index da208fc42..2d7b3b080 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java
@@ -29,6 +29,7 @@
package com.jogamp.opengl.test.junit.jogl.util.texture;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
import com.jogamp.opengl.test.junit.util.UITestCase;
import javax.media.opengl.GLProfile;
@@ -114,7 +115,7 @@ public class TestTexture01AWT extends UITestCase {
// create texture
TextureData textureData = AWTTextureIO.newTextureData(caps.getGLProfile(), textureImage, false);
- glCanvas.addGLEventListener(new TextureGL2ListenerDraw1(textureData));
+ glCanvas.addGLEventListener(new TextureDraw01GL2Listener(textureData));
Animator animator = new Animator(glCanvas);
frame.setVisible(true);
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 89f8863d7..ae4d2c377 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
@@ -39,8 +39,6 @@ public class TestTextureSequence01NEWT extends UITestCase {
window.setTitle("TestTextureSequence01NEWT");
// Size OpenGL to Video Surface
window.setSize(width, height);
- window.setFullscreen(false);
- window.setSize(width, height);
final TextureSequenceDemo01 texSource = new TextureSequenceDemo01(useBuildInTexLookup);
window.addGLEventListener(new GLEventListener() {
@Override