summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java)4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java210
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java196
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java101
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestJScrollPaneMixHwLw01AWT.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java167
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java186
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java51
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java207
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java119
15 files changed, 1177 insertions, 180 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java
index 0ac75d424..692a3181b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java
@@ -43,7 +43,7 @@ import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.Test;
-public class TestPointsNEWT extends UITestCase {
+public class TestGLPointsNEWT extends UITestCase {
static int width, height;
@BeforeClass
@@ -151,6 +151,6 @@ public class TestPointsNEWT extends UITestCase {
} catch (Exception ex) { ex.printStackTrace(); }
}
}
- org.junit.runner.JUnitCore.main(TestPointsNEWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestGLPointsNEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java
new file mode 100644
index 000000000..c699e6304
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java
@@ -0,0 +1,210 @@
+/**
+ * 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.acore;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.GLExtensions;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+public class TestGLUnitsNEWT extends UITestCase {
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ width = 512;
+ height = 512;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ class UnitTester implements GLEventListener {
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println("GL UnitTester");
+ System.err.println(" GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println(" GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println(" GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+ System.err.println(" GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber());
+ System.err.println(" GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
+ System.err.println(" GL Profile: "+gl.getGLProfile());
+ System.err.println(" GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString());
+ System.err.println(" GL:" + gl + ", " + gl.getContext().getGLVersion());
+
+ final int _glerr = gl.glGetError(); // clear pre-error
+ System.err.println(" - pre GL-Error 0x"+Integer.toHexString(_glerr));
+
+ final int[] val = new int[1];
+ final int[] glerr = new int[] { GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR };
+ int i=0;
+
+ val[0]=0;
+ gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0);
+ System.out.println(" - GL_MAX_TEXTURE_SIZE: " + val[0]);
+ glerr[i] = gl.glGetError(); // clear pre-error
+ System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
+ i++;
+
+ val[0]=0;
+ gl.glGetIntegerv(GL2ES2.GL_ACTIVE_TEXTURE, val, 0);
+ System.out.println(" - GL_ACTIVE_TEXTURE: " + val[0]);
+ glerr[i] = gl.glGetError(); // clear pre-error
+ System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
+ i++;
+
+ if(gl.isGL2ES2()) {
+ val[0]=0;
+ gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, val, 0);
+ System.out.println(" - GL_MAX_TEXTURE_IMAGE_UNITS: " + val[0]);
+ glerr[i] = gl.glGetError(); // clear pre-error
+ System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
+ }
+ i++;
+
+ if( gl.hasFullFBOSupport() || gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments) ) {
+ val[0]=0;
+ gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0);
+ System.out.println(" - GL_MAX_COLOR_ATTACHMENTS: " + val[0]);
+ glerr[i] = gl.glGetError(); // clear pre-error
+ System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
+ }
+ i++;
+
+ if( gl.hasFullFBOSupport() ) {
+ val[0]=0;
+ gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0);
+ System.out.println(" - GL_MAX_SAMPLES: " + val[0]);
+ glerr[i] = gl.glGetError(); // clear pre-error
+ System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
+ }
+ i++;
+
+ boolean ok = true;
+ String res="";
+ for(int j=0; j<i; j++) {
+ switch(j) {
+ case 0: res += "GL_MAX_TEXTURE_SIZE"; break;
+ case 1: res += "GL_ACTIVE_TEXTURE"; break;
+ case 2: res += "GL_MAX_TEXTURE_IMAGE_UNITS"; break;
+ case 3: res += "GL_MAX_COLOR_ATTACHMENTS"; break;
+ case 4: res += "GL_MAX_SAMPLES"; break;
+ }
+ if(GL.GL_NO_ERROR == glerr[j]) {
+ res += " OK, ";
+ } else {
+ res += " ERROR, ";
+ ok = false;
+ }
+ }
+ Assert.assertTrue(res, ok);
+ }
+
+ @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) {
+ }
+ }
+
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setTitle(getSimpleTestName("."));
+
+ UnitTester demo = new UnitTester();
+
+ glWindow.addGLEventListener(demo);
+
+ glWindow.setSize(width, height);
+ glWindow.setVisible(true);
+ glWindow.display();
+
+ glWindow.destroy();
+ }
+
+ @Test
+ public void test01_ES1() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GLES1)) { System.err.println("GLES1 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
+ runTestGL(caps);
+ }
+
+ @Test
+ public void test02__ES2() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ runTestGL(caps);
+ }
+
+ @Test
+ public void test03_GL2() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ runTestGL(caps);
+ }
+
+ @Test
+ public void test04_GL3() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL3)) { System.err.println("GL3 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL3));
+ runTestGL(caps);
+ }
+
+ @Test
+ public void test05_GL4() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL4)) { System.err.println("GL4 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL4));
+ runTestGL(caps);
+ }
+
+ public static void main(String args[]) {
+ org.junit.runner.JUnitCore.main(TestGLUnitsNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java
new file mode 100644
index 000000000..8b88a8615
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java
@@ -0,0 +1,196 @@
+package com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.BorderLayout;
+// import java.awt.Canvas;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.GraphicsConfiguration;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.io.IOException;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.WindowConstants;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.FPSAnimator;
+
+/**
+ * Documenting Bug 642 (related to Bug 586)
+ *
+ * <p>
+ * JSplitPane cannot mix hw/lw components, only if setting property '-Dsun.awt.disableMixing=true'.
+ * </p>
+ * See Bug 586
+ * See git commit '8df12ca151dfc577c90b485d4ebfe491b88e55aa'.
+ */
+public class TestBug642JSplitPaneMixHwLw01AWT extends UITestCase {
+ static long durationPerTest = 500;
+
+ static {
+ // too late: use at cmd-line '-Dsun.awt.disableMixing=true' works
+ // System.setProperty("sun.awt.disableMixing", "true");
+ }
+
+ /**
+ * Doesn't work either ..
+ */
+ @SuppressWarnings("serial")
+ public static class TransparentJScrollPane extends JScrollPane {
+
+ public TransparentJScrollPane(Component view) {
+ super(view);
+
+ setOpaque(false);
+
+ try {
+ ReflectionUtil.callStaticMethod(
+ "com.sun.awt.AWTUtilities", "setComponentMixingCutoutShape",
+ new Class<?>[] { Component.class, Shape.class },
+ new Object[] { this, new Rectangle() } ,
+ GraphicsConfiguration.class.getClassLoader());
+ System.err.println("com.sun.awt.AWTUtilities.setComponentMixingCutoutShape(..) passed");
+ } catch (RuntimeException re) {
+ System.err.println("com.sun.awt.AWTUtilities.setComponentMixingCutoutShape(..) failed: "+re.getMessage());
+ }
+ }
+
+ @Override
+ public void setOpaque(boolean isOpaque) {
+ }
+ }
+
+ protected void runTestGL(GLCapabilities caps, boolean useGLJPanel, boolean useContainer) throws InterruptedException {
+ final String typeS = useGLJPanel ? "LW" : "HW";
+ final JFrame frame = new JFrame("Mix Hw/Lw Swing - Canvas "+typeS);
+ Assert.assertNotNull(frame);
+
+ final Dimension f_sz = new Dimension(824,568);
+ // final Dimension f_sz = new Dimension(600,400);
+ // final Dimension glc_sz = new Dimension(500,600);
+
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ final Component glComp;
+ final GLAutoDrawable glad;
+ if(useGLJPanel) {
+ final GLJPanel glJPanel = new GLJPanel(new GLCapabilities(GLProfile.getDefault()));
+ Assert.assertNotNull(glJPanel);
+ glJPanel.addGLEventListener(new GearsES2());
+ glComp = glJPanel;
+ glad = glJPanel;
+ } else {
+ final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
+ Assert.assertNotNull(glCanvas);
+ glCanvas.addGLEventListener(new GearsES2());
+ if( useContainer ) {
+ final Container cont = new Container();
+ cont.setLayout(new BorderLayout());
+ cont.add(glCanvas, BorderLayout.CENTER);
+ glComp = cont;
+ } else {
+ glComp = glCanvas;
+ }
+ glad = glCanvas;
+ }
+
+ final Container contentPane = frame.getContentPane();
+
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ splitPane.setResizeWeight(0.5d);
+ splitPane.setLeftComponent(glComp);
+ // splitPane.setLeftComponent(new JPanel());
+ // splitPane.setLeftComponent(new Canvas());
+ splitPane.setRightComponent(new JPanel());
+ contentPane.add(splitPane, BorderLayout.CENTER);
+
+ final GLAnimatorControl animator = useGLJPanel ? new FPSAnimator(glad, 60) : new Animator(glad);
+ animator.start();
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setPreferredSize(f_sz);
+ frame.setSize(f_sz.width+1, f_sz.height+1); // trick to force pack() to work!
+ frame.pack();
+ frame.setVisible(true);
+ // however, Hw/Lw mixing is still a problem ..
+ }});
+ } catch (Throwable t) {
+ t.printStackTrace();
+ Assume.assumeNoException(t);
+ }
+
+ animator.setUpdateFPSFrames(60, System.err);
+ Thread.sleep(durationPerTest);
+
+ animator.stop();
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.dispose();
+ }});
+ } catch (Throwable t) {
+ t.printStackTrace();
+ Assume.assumeNoException(t);
+ }
+ }
+
+ @Test
+ public void test01JSplitPaneWithHwGLCanvasPlain() throws InterruptedException {
+ GLProfile glp = GLProfile.getGL2ES2();
+ GLCapabilities caps = new GLCapabilities(glp);
+ runTestGL(caps, false, false);
+ }
+
+ @Test
+ public void test02JSplitPaneWithHwGLCanvasContainer() throws InterruptedException {
+ GLProfile glp = GLProfile.getGL2ES2();
+ GLCapabilities caps = new GLCapabilities(glp);
+ runTestGL(caps, false, true);
+ }
+
+ @Test
+ public void test03JSplitPaneWithLwGLJPanel() throws InterruptedException {
+ GLProfile glp = GLProfile.getGL2ES2();
+ GLCapabilities caps = new GLCapabilities(glp);
+ runTestGL(caps, true, false);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ durationPerTest = MiscUtils.atol(args[++i], durationPerTest);
+ }
+ }
+ /**
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ System.err.println(stdin.readLine());
+ */
+ System.out.println("durationPerTest: "+durationPerTest);
+ String tstname = TestBug642JSplitPaneMixHwLw01AWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java
new file mode 100644
index 000000000..74e5d6cb7
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java
@@ -0,0 +1,101 @@
+/**
+ * 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.awt;
+
+import javax.media.opengl.awt.GLCanvas;
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class TestIsRealizedConcurrency01AWT extends UITestCase {
+ static long durationPerTest = 500; // ms
+
+ @Test
+ public void testAddRemove() throws InterruptedException, InvocationTargetException {
+ final Dimension f_sz = new Dimension(512, 512);
+
+ final GLCanvas glCanvas = new GLCanvas();
+ Assert.assertNotNull(glCanvas);
+ glCanvas.addGLEventListener(new GearsES2());
+
+ final Animator animator = new Animator(glCanvas);
+ animator.start();
+
+ final Frame frame = new Frame("Frame");
+ Assert.assertNotNull(frame);
+ frame.add(glCanvas);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setLocation(0, 0);
+ frame.setPreferredSize(f_sz);
+ frame.setSize(f_sz);
+ frame.pack();
+ frame.setVisible(true);
+ }});
+ Thread.sleep(durationPerTest/2);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas);
+ frame.validate();
+ frame.add(glCanvas);
+ frame.validate();
+ }});
+ Thread.sleep(durationPerTest/2);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ glCanvas.destroy();
+ frame.dispose();
+ }});
+
+ animator.stop();
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestIsRealizedConcurrency01AWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestJScrollPaneMixHwLw01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestJScrollPaneMixHwLw01AWT.java
index bb525c949..8868d255d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestJScrollPaneMixHwLw01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestJScrollPaneMixHwLw01AWT.java
@@ -77,7 +77,8 @@ public class TestJScrollPaneMixHwLw01AWT extends UITestCase {
}
protected void runTestGL(GLCapabilities caps, boolean useJScroll) throws InterruptedException {
- final JFrame frame = new JFrame("Mix Hw/Lw Swing");
+ final String typeS = useJScroll ? "LW" : "HW";
+ final JFrame frame = new JFrame("Mix Hw/Lw Swing - ScrollPane "+typeS);
Assert.assertNotNull(frame);
final Dimension f_sz = new Dimension(600,400);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index a3023538f..21c9f3535 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -152,26 +152,26 @@ public class GearsES2 implements GLEventListener {
st.uniform(gl, colorU);
if(null == gear1) {
- gear1 = new GearsObjectES2(1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear1 = new GearsObjectES2(st, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
System.err.println("gear1 created: "+gear1);
} else {
- gear1 = new GearsObjectES2(gear1, pmvMatrix, pmvMatrixUniform, colorU);
+ gear1 = new GearsObjectES2(gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
System.err.println("gear1 reused: "+gear1);
}
if(null == gear2) {
- gear2 = new GearsObjectES2(0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear2 = new GearsObjectES2(st, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
System.err.println("gear2 created: "+gear2);
} else {
- gear2 = new GearsObjectES2(gear2, pmvMatrix, pmvMatrixUniform, colorU);
+ gear2 = new GearsObjectES2(gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
System.err.println("gear2 reused: "+gear2);
}
if(null == gear3) {
- gear3 = new GearsObjectES2(1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear3 = new GearsObjectES2(st, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
System.err.println("gear3 created: "+gear3);
} else {
- gear3 = new GearsObjectES2(gear3, pmvMatrix, pmvMatrixUniform, colorU);
+ gear3 = new GearsObjectES2(gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
System.err.println("gear3 reused: "+gear3);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
index 32cc4c4d9..eb9647949 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
@@ -36,31 +36,45 @@ import com.jogamp.opengl.util.glsl.ShaderState;
* @author Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
*/
public class GearsObjectES2 extends GearsObject {
- PMVMatrix pmvMatrix;
- GLUniformData pmvMatrixUniform;
- GLUniformData colorUniform;
+ final PMVMatrix pmvMatrix;
+ final GLUniformData pmvMatrixUniform;
+ final GLUniformData colorUniform;
+ final ShaderState st;
- public GearsObjectES2(float inner_radius, float outer_radius, float width,
- int teeth, float tooth_depth,
- PMVMatrix pmvMatrix,
- GLUniformData pmvMatrixUniform,
- GLUniformData colorUniform)
+ public GearsObjectES2(ShaderState st, float inner_radius, float outer_radius,
+ float width, int teeth,
+ float tooth_depth,
+ PMVMatrix pmvMatrix,
+ GLUniformData pmvMatrixUniform, GLUniformData colorUniform)
{
super(inner_radius, outer_radius, width, teeth, tooth_depth);
this.pmvMatrix = pmvMatrix;
this.pmvMatrixUniform = pmvMatrixUniform;
this.colorUniform = colorUniform;
+ this.st = st;
+ associate(st);
}
public GearsObjectES2(GearsObjectES2 shared,
- PMVMatrix pmvMatrix,
- GLUniformData pmvMatrixUniform,
- GLUniformData colorUniform)
+ ShaderState st,
+ PMVMatrix pmvMatrix,
+ GLUniformData pmvMatrixUniform, GLUniformData colorUniform)
{
super(shared);
this.pmvMatrix = pmvMatrix;
this.pmvMatrixUniform = pmvMatrixUniform;
this.colorUniform = colorUniform;
+ this.st = st;
+ associate(st);
+ }
+
+ private void associate(ShaderState st) {
+ frontFace.associate(st, true);
+ frontSide.associate(st, true);
+ backFace.associate(st, true);
+ backSide.associate(st, true);
+ outwardFace.associate(st, true);
+ insideRadiusCyl.associate(st, true);
}
@Override
@@ -83,7 +97,6 @@ public class GearsObjectES2 extends GearsObject {
@Override
public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) {
final GL2ES2 gl = _gl.getGL2ES2();
- final ShaderState st = ShaderState.getShaderState(gl);
pmvMatrix.glPushMatrix();
pmvMatrix.glTranslatef(x, y, 0f);
pmvMatrix.glRotatef(angle, 0f, 0f, 1f);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
index 691e08ed2..98641398d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
@@ -117,7 +117,7 @@ public class MultisampleDemoES2 implements GLEventListener {
4, GL.GL_FLOAT, // color
0, GL.GL_FLOAT, // normal
0, GL.GL_FLOAT, // texCoords
- GL.GL_STATIC_DRAW);
+ GL.GL_STATIC_DRAW, st);
final int numSteps = 20;
final double increment = Math.PI / numSteps;
final double radius = 1;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
index c2285ba25..361c2916a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
@@ -40,8 +40,7 @@ public class GLSLMiscHelper {
public static final int frames_perftest = 600; // frames
public static final int frames_warmup = 100; // frames
- public static void validateGLArrayDataServerState(GL2ES2 gl, GLArrayDataServer data) {
- final ShaderState st = ShaderState.getShaderState(gl);
+ public static void validateGLArrayDataServerState(GL2ES2 gl, ShaderState st, GLArrayDataServer data) {
int[] qi = new int[1];
if(null != st) {
Assert.assertEquals(data, st.getAttribute(data.getName()));
@@ -66,7 +65,7 @@ public class GLSLMiscHelper {
}
}
- public static void displayVCArrays(GLDrawable drawable, GL2ES2 gl, boolean preEnable, GLArrayDataServer vertices, GLArrayDataServer colors, boolean postDisable, int num, long postDelay) throws InterruptedException {
+ public static void displayVCArrays(GLDrawable drawable, GL2ES2 gl, ShaderState st, boolean preEnable, GLArrayDataServer vertices, GLArrayDataServer colors, boolean postDisable, int num, long postDelay) throws InterruptedException {
System.err.println("screen #"+num);
if(preEnable) {
vertices.enableBuffer(gl, true);
@@ -81,8 +80,8 @@ public class GLSLMiscHelper {
Assert.assertTrue(vertices.enabled());
Assert.assertTrue(colors.enabled());
- validateGLArrayDataServerState(gl, vertices);
- validateGLArrayDataServerState(gl, colors);
+ validateGLArrayDataServerState(gl, st, vertices);
+ validateGLArrayDataServerState(gl, st, colors);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
@@ -111,88 +110,98 @@ public class GLSLMiscHelper {
drawable.swapBuffers();
}
- public static GLArrayDataServer createRSVertices0(GL2ES2 gl, int location) {
- final ShaderState st = ShaderState.getShaderState(gl);
-
+ public static GLArrayDataServer createVertices(GL2ES2 gl, ShaderState st, int shaderProgram, int location, float[] vertices) {
+ if(null != st && 0 != shaderProgram) {
+ throw new InternalError("Use either ShaderState _or_ shader-program, not both");
+ }
+ if(null == st && 0 == shaderProgram) {
+ throw new InternalError("Pass a valid ShaderState _xor_ shader-program, not none");
+ }
// Allocate Vertex Array0
- GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- if(0<=location) {
- st.bindAttribLocation(gl, location, vertices0);
+ GLArrayDataServer vDataArray = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ if(null != st) {
+ st.ownAttribute(vDataArray, true);
+ if(0<=location) {
+ st.bindAttribLocation(gl, location, vDataArray);
+ }
+ } else {
+ if(0<=location) {
+ vDataArray.setLocation(gl, shaderProgram, location);
+ } else {
+ vDataArray.setLocation(gl, shaderProgram);
+ }
}
- Assert.assertTrue(vertices0.isVBO());
- Assert.assertTrue(vertices0.isVertexAttribute());
- Assert.assertTrue(!vertices0.isVBOWritten());
- Assert.assertTrue(!vertices0.sealed());
- vertices0.putf(-2); vertices0.putf(2); vertices0.putf(0);
- vertices0.putf(2); vertices0.putf(2); vertices0.putf(0);
- vertices0.putf(-2); vertices0.putf(-2); vertices0.putf(0);
- vertices0.putf(2); vertices0.putf(-2); vertices0.putf(0);
- vertices0.seal(gl, true);
- Assert.assertTrue(vertices0.isVBOWritten());
- Assert.assertTrue(vertices0.sealed());
- Assert.assertEquals(4, vertices0.getElementCount());
+ Assert.assertTrue(vDataArray.isVBO());
+ Assert.assertTrue(vDataArray.isVertexAttribute());
+ Assert.assertTrue(!vDataArray.isVBOWritten());
+ Assert.assertTrue(!vDataArray.sealed());
+ int i=0;
+ vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]);
+ vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]);
+ vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]);
+ vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]); vDataArray.putf(vertices[i++]);
+ vDataArray.seal(gl, true);
+ Assert.assertTrue(vDataArray.isVBOWritten());
+ Assert.assertTrue(vDataArray.sealed());
+ Assert.assertEquals(4, vDataArray.getElementCount());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
Assert.assertEquals(0, gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); // should be cleared ASAP
- validateGLArrayDataServerState(gl, vertices0);
- return vertices0;
+ validateGLArrayDataServerState(gl, st, vDataArray);
+ return vDataArray;
}
+ public static float[] vertices0 = new float[] { -2f, 2f, 0f,
+ 2f, 2f, 0f,
+ -2f, -2f, 0f,
+ 2f, -2f, 0f };
- public static GLArrayDataServer createRSVertices1(GL2ES2 gl) {
- GLArrayDataServer vertices1 = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- Assert.assertTrue(vertices1.isVBO());
- Assert.assertTrue(vertices1.isVertexAttribute());
- Assert.assertTrue(!vertices1.isVBOWritten());
- Assert.assertTrue(!vertices1.sealed());
- vertices1.putf(-2); vertices1.putf(1); vertices1.putf(0);
- vertices1.putf(2); vertices1.putf(1); vertices1.putf(0);
- vertices1.putf(-2); vertices1.putf(-1); vertices1.putf(0);
- vertices1.putf(2); vertices1.putf(-1); vertices1.putf(0);
- vertices1.seal(gl, true);
- Assert.assertTrue(vertices1.isVBOWritten());
- Assert.assertTrue(vertices1.sealed());
- Assert.assertEquals(4, vertices1.getElementCount());
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
- Assert.assertEquals(0, gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); // should be cleared ASAP
- validateGLArrayDataServerState(gl, vertices1);
- return vertices1;
- }
-
- public static GLArrayDataServer createRSColors0(GL2ES2 gl, int location) {
- final ShaderState st = ShaderState.getShaderState(gl);
- GLArrayDataServer colors0 = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- if(0<=location) {
- st.bindAttribLocation(gl, location, colors0);
- }
- colors0.putf(1); colors0.putf(0); colors0.putf(0); colors0.putf(1);
- colors0.putf(0); colors0.putf(0); colors0.putf(1); colors0.putf(1);
- colors0.putf(1); colors0.putf(0); colors0.putf(0); colors0.putf(1);
- colors0.putf(1); colors0.putf(0); colors0.putf(0); colors0.putf(1);
- colors0.seal(gl, true);
- Assert.assertTrue(colors0.isVBO());
- Assert.assertTrue(colors0.isVertexAttribute());
- Assert.assertTrue(colors0.isVBOWritten());
- Assert.assertTrue(colors0.sealed());
+ public static float[] vertices1 = new float[] { -2f, 1f, 0f,
+ 2f, 1f, 0f,
+ -2f, -1f, 0f,
+ 2f, -1f, 0f };
+
+ public static GLArrayDataServer createColors(GL2ES2 gl, ShaderState st, int shaderProgram, int location, float[] colors) {
+ if(null != st && 0 != shaderProgram) {
+ throw new InternalError("Use either ShaderState _or_ shader-program, not both");
+ }
+ if(null == st && 0 == shaderProgram) {
+ throw new InternalError("Pass a valid ShaderState _xor_ shader-program, not none");
+ }
+ GLArrayDataServer cDataArray = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ if(null != st) {
+ st.ownAttribute(cDataArray, true);
+ if(0<=location) {
+ st.bindAttribLocation(gl, location, cDataArray);
+ }
+ } else {
+ if(0<=location) {
+ cDataArray.setLocation(gl, shaderProgram, location);
+ } else {
+ cDataArray.setLocation(gl, shaderProgram);
+ }
+ }
+ int i=0;
+ cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]);
+ cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]);
+ cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]);
+ cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]); cDataArray.putf(colors[i++]);
+ cDataArray.seal(gl, true);
+ Assert.assertTrue(cDataArray.isVBO());
+ Assert.assertTrue(cDataArray.isVertexAttribute());
+ Assert.assertTrue(cDataArray.isVBOWritten());
+ Assert.assertTrue(cDataArray.sealed());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
Assert.assertEquals(0, gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); // should be cleared ASAP
- validateGLArrayDataServerState(gl, colors0);
- return colors0;
+ validateGLArrayDataServerState(gl, st, cDataArray);
+ return cDataArray;
}
+ public static float[] colors0 = new float[] { 1f, 0f, 0f, 1f,
+ 0f, 0f, 1f, 1f,
+ 1f, 0f, 0f, 1f,
+ 1f, 0f, 1f, 1f };
+
+ public static float[] colors1 = new float[] { 1f, 0f, 1f, 1f,
+ 0f, 1f, 0f, 1f,
+ 1f, 0f, 1f, 1f,
+ 1f, 0f, 1f, 1f };
- public static GLArrayDataServer createRSColors1(GL2ES2 gl) {
- // Allocate Color Array1
- GLArrayDataServer colors1 = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- colors1.putf(1); colors1.putf(0); colors1.putf(1); colors1.putf(1);
- colors1.putf(0); colors1.putf(1); colors1.putf(0); colors1.putf(1);
- colors1.putf(1); colors1.putf(0); colors1.putf(1); colors1.putf(1);
- colors1.putf(1); colors1.putf(0); colors1.putf(1); colors1.putf(1);
- colors1.seal(gl, true);
- Assert.assertTrue(colors1.isVBO());
- Assert.assertTrue(colors1.isVertexAttribute());
- Assert.assertTrue(colors1.isVBOWritten());
- Assert.assertTrue(colors1.sealed());
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
- Assert.assertEquals(0, gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); // should be cleared ASAP
- validateGLArrayDataServerState(gl, colors1);
- return colors1;
- }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
index ab4b2d8b6..04108eda5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
@@ -60,7 +60,123 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
static final int colors0_loc = 1;
@Test
- public void testShaderState01Validation() throws InterruptedException {
+ public void test00NoShaderState_Validation() throws InterruptedException {
+ // preset ..
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
+ System.err.println(winctx.context);
+
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ // test code ..
+ final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class,
+ "shader", "shader/bin", "RedSquareShader", true);
+ final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class,
+ "shader", "shader/bin", "RedSquareShader", true);
+ rsVp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp);
+ rsFp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp);
+
+ final ShaderProgram sp = new ShaderProgram();
+ Assert.assertTrue(0 == sp.program());
+
+ sp.add(gl, rsVp, System.err);
+ sp.add(gl, rsFp, System.err);
+
+ Assert.assertTrue(0 != sp.program());
+ Assert.assertTrue(!sp.inUse());
+ Assert.assertTrue(!sp.linked());
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ Assert.assertTrue( sp.link(gl, System.err) );
+ sp.useProgram(gl, true);
+
+ // Allocate Vertex Array0
+ final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, null, sp.program(), vertices0_loc, GLSLMiscHelper.vertices0);
+ System.err.println("vertices0: " + vertices0);
+ vertices0.enableBuffer(gl, false);
+ Assert.assertEquals(vertices0_loc, vertices0.getLocation());
+
+ // Allocate Color Array0
+ final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, null, sp.program(), colors0_loc, GLSLMiscHelper.colors0);
+ System.err.println("colors0: " + colors0);
+ colors0.enableBuffer(gl, false);
+ Assert.assertEquals(colors0_loc, colors0.getLocation());
+
+ Assert.assertTrue(sp.link(gl, System.err));
+ Assert.assertTrue(sp.linked());
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ Assert.assertEquals(vertices0_loc, vertices0.getLocation());
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, null, vertices0);
+
+ Assert.assertEquals(colors0_loc, colors0.getLocation());
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, null, colors0);
+
+ sp.useProgram(gl, true);
+ Assert.assertTrue(sp.inUse());
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ // setup mgl_PMVMatrix
+ final PMVMatrix pmvMatrix = new PMVMatrix();
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ pmvMatrixUniform.setLocation(gl, sp.program());
+ gl.glUniform(pmvMatrixUniform);
+
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ // Allocate Vertex Array1
+ final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, null, sp.program(), -1, GLSLMiscHelper.vertices1);
+ System.err.println("vertices1: " + vertices1);
+ vertices1.enableBuffer(gl, false);
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, null, vertices1);
+
+ // Allocate Color Array1
+ final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, null, sp.program(), -1, GLSLMiscHelper.colors1);
+ System.err.println("colors1: " + colors1);
+ colors1.enableBuffer(gl, false);
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, null, colors1);
+
+ // misc GL setup
+ gl.glClearColor(0, 0, 0, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ // reshape
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.gluPerspective(45.0F, (float) drawable.getWidth() / (float) drawable.getHeight(), 1.0F, 100.0F);
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, -10);
+ gl.glUniform(pmvMatrixUniform);
+
+ gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ // display #1 vertices0 / colors0 (post-disable)
+ GLSLMiscHelper.displayVCArrays(drawable, gl, null, true, vertices0, colors0, true, 1, durationPerTest);
+
+ // display #2 #1 vertices1 / colors1 (post-disable)
+ GLSLMiscHelper.displayVCArrays(drawable, gl, null, true, vertices1, colors1, true, 2, durationPerTest);
+
+ // display #3 vertices0 / colors0 (post-disable)
+ GLSLMiscHelper.displayVCArrays(drawable, gl, null, true, vertices0, colors0, true, 3, durationPerTest);
+
+ // cleanup
+ sp.useProgram(gl, false);
+ sp.destroy(gl);
+ vertices1.destroy(gl);
+ colors0.destroy(gl);
+ colors1.destroy(gl);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+
+ @Test
+ public void test01ShaderState_Validation() throws InterruptedException {
// preset ..
final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
@@ -95,33 +211,27 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
Assert.assertTrue(!sp.inUse());
Assert.assertTrue(!sp.linked());
- Assert.assertEquals(null, ShaderState.getShaderState(gl));
- st.setShaderState(gl); // pre-use attach
- Assert.assertEquals(st, ShaderState.getShaderState(gl));
-
// Allocate Vertex Array0
- final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, vertices0_loc);
+ final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, vertices0_loc, GLSLMiscHelper.vertices0);
System.err.println("vertices0: " + vertices0);
vertices0.enableBuffer(gl, false);
Assert.assertEquals(vertices0_loc, vertices0.getLocation());
- st.ownAttribute(vertices0, true);
// Allocate Color Array0
- final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, colors0_loc);
+ final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, colors0_loc, GLSLMiscHelper.colors0);
System.err.println("colors0: " + colors0);
colors0.enableBuffer(gl, false);
Assert.assertEquals(colors0_loc, colors0.getLocation());
- st.ownAttribute(colors0, true);
Assert.assertTrue(sp.link(gl, System.err));
Assert.assertTrue(sp.linked());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
Assert.assertEquals(vertices0_loc, vertices0.getLocation());
- GLSLMiscHelper.validateGLArrayDataServerState(gl, vertices0);
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices0);
Assert.assertEquals(colors0_loc, colors0.getLocation());
- GLSLMiscHelper.validateGLArrayDataServerState(gl, colors0);
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors0);
st.useProgram(gl, true);
Assert.assertTrue(sp.inUse());
@@ -138,18 +248,16 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix"));
// Allocate Vertex Array1
- final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl);
+ final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices1);
System.err.println("vertices1: " + vertices1);
vertices1.enableBuffer(gl, false);
- GLSLMiscHelper.validateGLArrayDataServerState(gl, vertices1);
- st.ownAttribute(vertices1, true);
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices1);
// Allocate Color Array1
- final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl);
+ final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors1);
System.err.println("colors1: " + colors1);
colors1.enableBuffer(gl, false);
- GLSLMiscHelper.validateGLArrayDataServerState(gl, colors1);
- st.ownAttribute(colors0, true);
+ GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors1);
// misc GL setup
gl.glClearColor(0, 0, 0, 1);
@@ -168,13 +276,13 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// display #1 vertices0 / colors0 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest);
// display #2 #1 vertices1 / colors1 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest);
// display #3 vertices0 / colors0 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 3, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest);
// cleanup
st.destroy(gl);
@@ -183,15 +291,15 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
}
@Test(timeout=240000)
- public void testShaderState00PerformanceSingleKeepEnabled() throws InterruptedException {
- testShaderState00PerformanceSingle(false);
+ public void test02ShaderState_PerformanceSingleKeepEnabled() throws InterruptedException {
+ testShaderState_PerformanceSingleImpl(false);
}
@Test(timeout=240000)
- public void testShaderState00PerformanceSingleToggleEnable() throws InterruptedException {
- testShaderState00PerformanceSingle(true);
+ public void test03ShaderState_PerformanceSingleToggleEnable() throws InterruptedException {
+ testShaderState_PerformanceSingleImpl(true);
}
- void testShaderState00PerformanceSingle(boolean toggleEnable) throws InterruptedException {
+ private void testShaderState_PerformanceSingleImpl(boolean toggleEnable) throws InterruptedException {
// preset ..
final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
@@ -226,13 +334,11 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
st.uniform(gl, pmvMatrixUniform);
// Allocate Vertex Array0
- final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, -1);
- st.ownAttribute(vertices0, true);
+ final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices0);
vertices0.enableBuffer(gl, toggleEnable ? false : true);
// Allocate Color Array0
- final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, -1);
- st.ownAttribute(colors0, true);
+ final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors0);
colors0.enableBuffer(gl, toggleEnable ? false : true);
// misc GL setup
@@ -252,7 +358,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
gl.setSwapInterval(0);
// validation ..
- GLSLMiscHelper.displayVCArrays(drawable, gl, toggleEnable, vertices0, colors0, toggleEnable, 1, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, toggleEnable, vertices0, colors0, toggleEnable, 1, 0);
// warmup ..
for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames++) {
@@ -280,7 +386,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
}
@Test(timeout=240000)
- public void testShaderState01PerformanceDouble() throws InterruptedException {
+ public void test04ShaderState_PerformanceDouble() throws InterruptedException {
// preset ..
final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
@@ -315,23 +421,19 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
st.uniform(gl, pmvMatrixUniform);
// Allocate Vertex Array0
- final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, -1);
- st.ownAttribute(vertices0, true);
+ final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices0);
vertices0.enableBuffer(gl, false);
// Allocate Vertex Array1
- final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl);
- st.ownAttribute(vertices1, true);
+ final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices1);
vertices1.enableBuffer(gl, false);
// Allocate Color Array0
- final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, -1);
- st.ownAttribute(colors0, true);
+ final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors0);
colors0.enableBuffer(gl, false);
// Allocate Color Array1
- final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl);
- st.ownAttribute(colors1, true);
+ final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors1);
colors1.enableBuffer(gl, false);
// misc GL setup
@@ -351,8 +453,8 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
gl.setSwapInterval(0);
// validation ..
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, 0);
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
// warmup ..
for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
@@ -397,7 +499,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
while(-1 == System.in.read()) ;
TestGLSLShaderState01NEWT tst = new TestGLSLShaderState01NEWT();
try {
- tst.testShaderState01PerformanceDouble();
+ tst.test04ShaderState_PerformanceDouble();
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
index 7022b7400..1ba7d9edb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
@@ -121,20 +121,15 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
st.attachShaderProgram(gl, sp0, false);
Assert.assertTrue(!sp0.inUse());
Assert.assertTrue(!sp0.linked());
- Assert.assertEquals(null, ShaderState.getShaderState(gl));
- st.setShaderState(gl); // pre-use attach
- Assert.assertEquals(st, ShaderState.getShaderState(gl));
// Allocate Vertex Array0
- final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, vertices0_loc);
- st.ownAttribute(vertices0, true);
+ final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, vertices0_loc, GLSLMiscHelper.vertices0);
System.err.println("vertices0: " + vertices0);
vertices0.enableBuffer(gl, false);
Assert.assertEquals(vertices0_loc, vertices0.getLocation());
// Allocate Color Array0
- final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, colors0_loc);
- st.ownAttribute(colors0, true);
+ final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, colors0_loc, GLSLMiscHelper.colors0);
System.err.println("colors0: " + colors0);
colors0.enableBuffer(gl, false);
Assert.assertEquals(colors0_loc, colors0.getLocation());
@@ -166,14 +161,12 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix"));
// Allocate Vertex Array1
- final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl);
- st.ownAttribute(vertices1, true);
+ final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices1);
System.err.println("vertices1: " + vertices1);
vertices1.enableBuffer(gl, false);
// Allocate Color Array1
- final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl);
- st.ownAttribute(colors1, true);
+ final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors1);
System.err.println("colors1: " + colors1);
colors1.enableBuffer(gl, false);
@@ -194,16 +187,16 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// display #1 vertices0 / colors0 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest);
// display #2 vertices1 / colors1 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest);
// display #3 vertices0 / colors0 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 3, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest);
// display #4 vertices1 / colors1 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 4, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 4, durationPerTest);
// SP1
st.attachShaderProgram(gl, sp1, true);
@@ -222,16 +215,16 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
}
// display #1 vertices0 / colors0 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 10, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 10, durationPerTest);
// display #2 vertices1 / colors1 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 20, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 20, durationPerTest);
// display #3 vertices0 / colors0 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 30, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 30, durationPerTest);
// display #4 vertices1 / colors1 (post-disable)
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 40, durationPerTest);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 40, durationPerTest);
// cleanup
st.destroy(gl);
@@ -286,23 +279,19 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
st.uniform(gl, pmvMatrixUniform);
// Allocate Vertex Array0
- final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, -1);
- st.ownAttribute(vertices0, true);
+ final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices0);
vertices0.enableBuffer(gl, false);
// Allocate Vertex Array1
- final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl);
- st.ownAttribute(vertices1, true);
+ final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices1);
vertices1.enableBuffer(gl, false);
// Allocate Color Array0
- final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, -1);
- st.ownAttribute(colors0, true);
+ final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors0);
colors0.enableBuffer(gl, false);
// Allocate Color Array1
- final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl);
- st.ownAttribute(colors1, true);
+ final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors1);
colors1.enableBuffer(gl, false);
// misc GL setup
@@ -323,11 +312,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
// validation ..
st.attachShaderProgram(gl, sp0, true);
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, 0);
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
st.attachShaderProgram(gl, sp1, true);
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, 0);
- GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
+ GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
// warmup ..
for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java
index 276fb17f9..c82e7def4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java
@@ -1,3 +1,30 @@
+/**
+ * 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;
import javax.media.opengl.GL;
@@ -68,8 +95,6 @@ class DemoGL2ES1ImmModeSink implements GLEventListener {
gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
gl.glLoadIdentity();
-
- gl.glViewport( 0, 0, width, height );
}
@Override
@@ -79,15 +104,13 @@ class DemoGL2ES1ImmModeSink implements GLEventListener {
gl.glClear( GL.GL_COLOR_BUFFER_BIT );
// draw a triangle filling the window
- gl.glLoadIdentity();
-
ims.glBegin(GL.GL_TRIANGLES);
ims.glColor3f( 1, 0, 0 );
ims.glVertex2f( 0, 0 );
ims.glColor3f( 0, 1, 0 );
- ims.glVertex2f( TestImmModeSinkES1NEWT.iWidth, 0 );
+ ims.glVertex2f( drawable.getWidth(), 0 );
ims.glColor3f( 0, 0, 1 );
- ims.glVertex2f( TestImmModeSinkES1NEWT.iWidth / 2, TestImmModeSinkES1NEWT.iHeight );
+ ims.glVertex2f( drawable.getWidth() / 2, drawable.getHeight() );
ims.glEnd(gl, true);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java
index b66a0955c..0df368615 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java
@@ -1,3 +1,30 @@
+/**
+ * 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;
import java.nio.ByteBuffer;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
new file mode 100644
index 000000000..b38ae85e8
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
@@ -0,0 +1,207 @@
+/**
+ * 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;
+
+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;
+
+import com.jogamp.opengl.util.ImmModeSink;
+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;
+
+public class DemoGL2ES2ImmModeSink implements GLEventListener {
+
+ private final ShaderState st;
+ private final PMVMatrix pmvMatrix;
+ private int glBufferUsage;
+ private ShaderProgram sp;
+ private GLUniformData pmvMatrixUniform;
+ private ImmModeSink ims;
+
+ public DemoGL2ES2ImmModeSink(boolean useVBO, boolean useShaderState) {
+ if(useShaderState) {
+ st = new ShaderState();
+ st.setVerbose(true);
+ } else {
+ st = null;
+ }
+ glBufferUsage = useVBO ? GL.GL_STATIC_DRAW : 0;
+ pmvMatrix = new PMVMatrix();
+ }
+
+ static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
+ static final String gl2_prelude = "#version 110\n";
+
+ public void init(GLAutoDrawable glad) {
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+
+ System.err.println("GL_VENDOR "+gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER "+gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION "+gl.glGetString(GL.GL_VERSION));
+
+ final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, DemoGL2ES2ImmModeSink.class,
+ "../demos/es2/shader", "../demos/es2/shader/bin", "mgl_default_xxx", true);
+ final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, DemoGL2ES2ImmModeSink.class,
+ "../demos/es2/shader", "../demos/es2/shader/bin", "mgl_default_xxx", true);
+
+ // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
+ int fp0Pos;
+ if(gl.isGLES2()) {
+ vp0.insertShaderSource(0, 0, es2_prelude[0]);
+ fp0Pos = fp0.insertShaderSource(0, 0, es2_prelude[0]);
+ } else {
+ vp0.insertShaderSource(0, 0, gl2_prelude);
+ fp0Pos = fp0.insertShaderSource(0, 0, gl2_prelude);
+ }
+ if(gl.isGLES2()) {
+ fp0Pos = fp0.insertShaderSource(0, fp0Pos, es2_prelude[1]);
+ }
+
+ sp = new ShaderProgram();
+ sp.add(gl, vp0, System.err);
+ sp.add(gl, fp0, System.err);
+ if( null != st ) {
+ st.attachShaderProgram(gl, sp, true);
+ } else {
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Could not link program: "+sp);
+ }
+ sp.useProgram(gl, true);
+ }
+
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ if(null != st) {
+ st.ownUniform(pmvMatrixUniform);
+ st.uniform(gl, pmvMatrixUniform);
+ } else {
+ if( pmvMatrixUniform.setLocation(gl, sp.program()) < 0 ) {
+ throw new GLException("Could not find location for uniform: "+pmvMatrixUniform+", "+sp);
+ }
+ gl.glUniform(pmvMatrixUniform);
+ }
+
+ // Using predef array names, see
+ // GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex);
+ if( null != st ) {
+ ims = ImmModeSink.createGLSL(40,
+ 3, GL.GL_FLOAT, // vertex
+ 4, GL.GL_FLOAT, // color
+ 0, GL.GL_FLOAT, // normal
+ 0, GL.GL_FLOAT, // texCoords
+ glBufferUsage, st);
+ } else {
+ ims = ImmModeSink.createGLSL(40,
+ 3, GL.GL_FLOAT, // vertex
+ 4, GL.GL_FLOAT, // color
+ 0, GL.GL_FLOAT, // normal
+ 0, GL.GL_FLOAT, // texCoords
+ glBufferUsage, sp.program());
+ }
+ final int numSteps = 20;
+ final double increment = Math.PI / numSteps;
+ final double radius = 1;
+ ims.glBegin(GL.GL_LINES);
+ for (int i = numSteps - 1; i >= 0; i--) {
+ ims.glVertex3f((float) (radius * Math.cos(i * increment)),
+ (float) (radius * Math.sin(i * increment)),
+ 0f);
+ ims.glColor4f( 1f, 1f, 1f, 1f );
+ ims.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)),
+ (float) (-1.0 * radius * Math.sin(i * increment)),
+ 0f);
+ ims.glColor4f( 1f, 1f, 1f, 1f );
+ }
+ ims.glEnd(gl, false);
+
+ if(null != st) {
+ st.useProgram(gl, false);
+ } else {
+ gl.glUseProgram(0);
+ }
+ }
+
+ public void dispose(GLAutoDrawable glad) {
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ ims.destroy(gl);
+ ims = null;
+ if(null != st) {
+ st.destroy(gl);
+ }
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glClear( GL.GL_COLOR_BUFFER_BIT );
+
+ // draw a triangle filling the window
+ ims.glBegin(GL.GL_TRIANGLES);
+ ims.glColor3f( 1, 0, 0 );
+ ims.glVertex2f( 0, 0 );
+ ims.glColor3f( 0, 1, 0 );
+ ims.glVertex2f( drawable.getWidth(), 0 );
+ ims.glColor3f( 0, 0, 1 );
+ ims.glVertex2f( drawable.getWidth() / 2, drawable.getHeight() );
+ ims.glEnd(gl, true);
+ }
+
+ // Unused routines
+ public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
+ System.err.println("reshape ..");
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+
+ // coordinate system origin at lower left with width and height same as the window
+ pmvMatrix.glOrthof( 0.0f, width, 0.0f, height, -1, 1 );
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ if(null != st) {
+ st.useProgram(gl, true);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+ } else {
+ gl.glUseProgram(sp.program());
+ gl.glUniform(pmvMatrixUniform);
+ gl.glUseProgram(0);
+ }
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java
new file mode 100644
index 000000000..48f1df757
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES2NEWT.java
@@ -0,0 +1,119 @@
+/**
+ * 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;
+
+import java.io.IOException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Testing the ImmModeSink w/ GL2ES1 context
+ */
+public class TestImmModeSinkES2NEWT extends UITestCase {
+ static int duration = 100;
+ static final int iWidth = 400;
+ static final int iHeight = 400;
+
+ static GLCapabilities getCaps(String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
+ System.out.println("Requested GL Caps: "+reqGLCaps);
+
+ //
+ // Create native windowing resources .. X11/Win/OSX
+ //
+ final GLWindow glad = GLWindow.create(reqGLCaps);
+ glad.addGLEventListener(demo);
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+ glad.addGLEventListener(snapshotGLEventListener);
+ glad.setSize(iWidth, iHeight);
+ glad.setVisible(true);
+
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display(); // initial resize/display
+
+ Thread.sleep(duration);
+
+ glad.destroy();
+ }
+
+ @Test
+ public void test05ImmSinkGL2ES2_VBOOff_Direct() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(false, false));
+ }
+
+ @Test
+ public void test05ImmSinkGL2ES2_VBOOff_ShaderState() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(false, true));
+ }
+
+ @Test
+ public void test06ImmSinkGL2ES2_VBOOn_Direct() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(true, false));
+ }
+
+ @Test
+ public void test06ImmSinkGL2ES2_VBOOn_ShaderState() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(true, true));
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ duration = MiscUtils.atoi(args[++i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestImmModeSinkES2NEWT.class.getName());
+ }
+
+}