summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/scripts/tests.sh5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TestAWTTextRendererUseVertexArrayBug464.java155
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererGLEventListener01.java124
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererTraceGL2Mock01.java137
4 files changed, 419 insertions, 2 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 27fae1f87..8b6350542 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -36,7 +36,7 @@ function jrun() {
#D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock"
#D_ARGS="-Dnewt.debug.EDT"
#D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all"
- D_ARGS="-Djogl.debug=all -Dnewt.debug=all"
+ #D_ARGS="-Djogl.debug=all -Dnewt.debug=all"
#D_ARGS="-Dnewt.debug=all"
#D_ARGS="-Dnativewindow.debug=all"
#D_ARGS="-Djogl.debug.GraphicsConfiguration"
@@ -94,7 +94,7 @@ function testawt() {
#
# awt (testawt)
#
-testawt com.jogamp.newt.impl.awt.opengl.VersionApplet $*
+#testawt com.jogamp.newt.impl.awt.opengl.VersionApplet $*
#testawt javax.media.opengl.awt.GLCanvas $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $*
@@ -104,6 +104,7 @@ testawt com.jogamp.newt.impl.awt.opengl.VersionApplet $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.TestGearsAWT
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.TestGearsGLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.texture.TestTexture01AWT
+testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464
#
# newt.awt (testawt)
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TestAWTTextRendererUseVertexArrayBug464.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TestAWTTextRendererUseVertexArrayBug464.java
new file mode 100644
index 000000000..fc19a6842
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TestAWTTextRendererUseVertexArrayBug464.java
@@ -0,0 +1,155 @@
+/**
+ * Copyright 2011 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.awt.text;
+
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.awt.GLCanvas;
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import java.awt.Frame;
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Test;
+
+/*
+ * Unit tests for Bug464
+ * Some ATI-Drivers crash the JVM if VBO-related glFunctions are called. This test checks
+ * if TextRenderer calls any of these functions while it's useVertexArray variable is set
+ * to false.
+ * 2D- and 3D-TextRendering is tested by creating a GLCanvas showing a simple line of text
+ * while filtering all glFunction calls by using a modified version of TraceGL2.
+ * VBO-related function are logged to the disallowedMethodCalls String of the GLEventListener
+ * instead of being executed (to prevent JVM crashes). Therefore, if the
+ * disallowedMethodCalls isn't an empty String after the test, the test fails.
+ *
+ * Other classes related to this test:
+ * TestTextRendererGLEventListener01
+ * TestTextRendererTraceGL2Mock01
+ */
+
+public class TestAWTTextRendererUseVertexArrayBug464 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+
+ private GLCanvas glCanvas;
+ private Frame frame;
+
+ @BeforeClass
+ public static void initClass() {
+ GLProfile.initSingleton(true);
+ glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ }
+
+ @Before
+ public void initTest() {
+ glCanvas = new GLCanvas(caps);
+
+ frame = new Frame("TextRenderer Test");
+ Assert.assertNotNull(frame);
+ frame.add(glCanvas);
+ frame.setSize(512, 512);
+ frame.setVisible(true);
+
+ }
+
+ @After
+ public void cleanupTest() {
+ frame.setVisible(false);
+ frame.remove(glCanvas);
+ glCanvas=null;
+ Assert.assertNotNull(frame);
+ frame.dispose();
+ frame=null;
+ }
+
+ @Test
+ public void testTextRendererDraw2D() throws InterruptedException {
+
+ TextRendererGLEventListener01 listener = new TextRendererGLEventListener01(1);
+ Assert.assertNotNull(listener);
+ glCanvas.addGLEventListener(listener);
+ Animator animator = new Animator(glCanvas);
+
+ animator.start();
+
+ Thread.sleep(500); // 500 ms
+
+ animator.stop();
+
+ String disallowedMethods = listener.getDisallowedMethodCalls();
+ if (!disallowedMethods.equals("")) {
+ Assert.fail("Following VBO-related glMethods have been called: "+ disallowedMethods);
+ }
+ }
+
+ @Test
+ public void testTextRendererDraw3D() throws InterruptedException {
+
+ TextRendererGLEventListener01 listener = new TextRendererGLEventListener01(2);
+ Assert.assertNotNull(listener);
+ glCanvas.addGLEventListener(listener);
+ Animator animator = new Animator(glCanvas);
+
+ animator.start();
+
+ Thread.sleep(500); // 500 ms
+
+ animator.stop();
+
+ String disallowedMethods = listener.getDisallowedMethodCalls();
+ if (!disallowedMethods.equals("")) {
+ Assert.fail("Following VBO-related glMethods have been called: "+ disallowedMethods);
+ }
+ }
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestAWTTextRendererUseVertexArrayBug464.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/awt/text/TextRendererGLEventListener01.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererGLEventListener01.java
new file mode 100644
index 000000000..b14704142
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererGLEventListener01.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright 2011 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.awt.text;
+
+import java.awt.Font;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import com.jogamp.opengl.util.awt.TextRenderer;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.glu.GLU;
+
+import org.junit.Assert;
+
+/*
+ * Unit tests for Bug464
+ * GLEventListener for unit test TestAWTTextRendererUseVertexArrayBug464. The display
+ * method renders the String "ABC123#+?" to the lower left corner of the canvas.
+ *
+ * The testNumber variable is used to switch between 2D- and 3D-textrendering in the display
+ * method.
+ * The disallowedMethodCalls variable is used to log VBO-related glFunction calls during
+ * the execution of the test.
+ *
+ * Other classes related to this test:
+ * TestAWTTextRendererUseVertexArrayBug464
+ * TextRendererTraceGL2Mock01
+ */
+
+public class TextRendererGLEventListener01 implements GLEventListener {
+ private GLU glu = new GLU();
+ private TextRenderer renderer;
+ private String text;
+ private String disallowedMethodCalls;
+ private int testNumber;
+
+ public TextRendererGLEventListener01(int testNumber) {
+ this.disallowedMethodCalls = "";
+ this.testNumber = testNumber;
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ renderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 36));
+ renderer.setUseVertexArrays(false);
+ Assert.assertNotNull(renderer);
+ Assert.assertFalse(renderer.getUseVertexArrays());
+
+ text = "ABC123#+?";
+
+ PrintStream nullStream = new PrintStream(new OutputStream(){ public void write(int b){}});
+ drawable.setGL(new TextRendererTraceGL2Mock01(drawable.getGL().getGL2(), nullStream, this));
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2 gl = drawable.getGL().getGL2();
+ gl.glMatrixMode(GL2ES1.GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluOrtho2D(0, 1, 0, 1);
+ gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ renderer.dispose();
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ if (disallowedMethodCalls.equals("")) {
+ if (testNumber == 1) {
+ renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.setColor(1.0f, 1.0f, 1.0f, 1.0f);
+ renderer.draw(text, 0, 0);
+ renderer.endRendering();
+ }
+ if (testNumber == 2) {
+ renderer.begin3DRendering();
+ renderer.setColor(1.0f, 1.0f, 1.0f, 1.0f);
+ renderer.draw3D(text, 0, 0, 0, 0.002f);
+ renderer.end3DRendering();
+ }
+ }
+ }
+
+ public void disallowedMethodCalled (String method) {
+ if (!disallowedMethodCalls.equals("")) {
+ disallowedMethodCalls += ", ";
+ }
+ disallowedMethodCalls += method;
+ }
+
+ public String getDisallowedMethodCalls() {
+ return this.disallowedMethodCalls;
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererTraceGL2Mock01.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererTraceGL2Mock01.java
new file mode 100644
index 000000000..63258a574
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TextRendererTraceGL2Mock01.java
@@ -0,0 +1,137 @@
+/**
+ * Copyright 2011 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.awt.text;
+
+import java.io.PrintStream;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+
+import javax.media.opengl.GL2;
+import javax.media.opengl.TraceGL2;
+
+import com.jogamp.common.nio.Buffers;
+
+/*
+ * Unit tests for Bug464
+ * Modified Version of TraceGL2 for unit test TestAWTTextRendererUseVertexArrayBug464.
+ * This class overrides all glFunctions related to VBO's according to
+ * http://code.google.com/p/glextensions/wiki/GL_ARB_vertex_buffer_object:
+ * glBindBuffer (glBindBufferARB)
+ * glDeleteBuffers (glDeleteBuffersARB)
+ * glGenBuffers (glGenBuffersARB)
+ * glIsBuffer (glIsBufferARB)
+ * glBufferData (glBufferDataARB)
+ * glBufferSubData (glBufferSubDataARB)
+ * glGetBufferSubData (glGetBufferSubDataARB)
+ * glMapBuffer (glMapBufferARB)
+ * glUnmapBuffer (glUnmapBufferARB)
+ * glGetBufferParameteriv (glGetBufferParameterivARB)
+ * glGetBufferPointerv (glGetBufferPointervARB)
+ * Calls to the overridden methods are logged to the disallowedMethodCalls variable of
+ * the GLEventListener instead of being passed to the downstreamGL object.
+ *
+ * Other classes related to this test:
+ * TestAWTTextRendererUseVertexArrayBug464
+ * TextRendererGLEventListener01
+ */
+
+public class TextRendererTraceGL2Mock01 extends TraceGL2 {
+
+ TextRendererGLEventListener01 listener;
+
+ public TextRendererTraceGL2Mock01(GL2 downstreamGL2, PrintStream stream, TextRendererGLEventListener01 listener) {
+ super(downstreamGL2, stream);
+ this.listener = listener;
+ }
+
+ @Override
+ public void glGetBufferSubData(int arg0, long arg1, long arg2, Buffer arg3) {
+ listener.disallowedMethodCalled("glGetBufferSubData");
+ }
+
+ @Override
+ public ByteBuffer glMapBuffer(int arg0, int arg1) {
+ listener.disallowedMethodCalled("glMapBuffer");
+ return Buffers.newDirectByteBuffer(0);
+ }
+
+ @Override
+ public void glGetBufferParameteriv(int arg0, int arg1, IntBuffer arg2) {
+ listener.disallowedMethodCalled("glGetBufferParameteriv");
+ }
+
+ @Override
+ public boolean glUnmapBuffer(int arg0) {
+ listener.disallowedMethodCalled("glUnmapBuffer");
+ return false;
+ }
+
+ @Override
+ public void glGenBuffers(int arg0, IntBuffer arg1) {
+ listener.disallowedMethodCalled("glGenBuffers");
+ }
+
+ @Override
+ public void glGenBuffers(int arg0, int[] arg1, int arg2) {
+ listener.disallowedMethodCalled("glGenBuffers");
+ }
+
+ @Override
+ public boolean glIsBuffer(int arg0) {
+ listener.disallowedMethodCalled("glIsBuffer");
+ return false;
+ }
+
+ @Override
+ public void glBindBuffer(int arg0, int arg1) {
+ listener.disallowedMethodCalled("glBindBuffer");
+ }
+
+ @Override
+ public void glDeleteBuffers(int arg0, int[] arg1, int arg2) {
+ listener.disallowedMethodCalled("glDeleteBuffers");
+ }
+
+ @Override
+ public void glBufferSubData(int arg0, long arg1, long arg2, Buffer arg3) {
+ listener.disallowedMethodCalled("glBufferSubData");
+ }
+
+ @Override
+ public void glGetBufferParameteriv(int arg0, int arg1, int[] arg2, int arg3) {
+ listener.disallowedMethodCalled("glGetBufferParameteriv");
+ }
+
+ @Override
+ public void glBufferData(int arg0, long arg1, Buffer arg2, int arg3) {
+ listener.disallowedMethodCalled("glBufferData");
+ }
+
+}