aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java44
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java97
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java161
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java142
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestES1FixedFunctionPipelineNEWT.java151
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES1NEWT.java226
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/UITestCase.java6
10 files changed, 669 insertions, 258 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index 40b351a75..5186fd7fd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -27,6 +27,7 @@ import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.GLProfile;
import com.jogamp.newt.Window;
@@ -37,12 +38,21 @@ import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
+import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
+import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
/**
* GearsES1.java <BR>
* @author Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
*/
public class GearsES1 implements GLEventListener {
+ private boolean debugFFPEmu = false;
+ private boolean verboseFFPEmu = false;
+ private boolean traceFFPEmu = false;
+ private boolean forceFFPEmu = false;
+ private boolean debug = false ;
+ private boolean trace = false ;
+
private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
@@ -63,6 +73,13 @@ public class GearsES1 implements GLEventListener {
this.swapInterval = 1;
}
+ public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
+ this.forceFFPEmu = forceFFPEmu;
+ this.verboseFFPEmu = verboseFFPEmu;
+ this.debugFFPEmu = debugFFPEmu;
+ this.traceFFPEmu = traceFFPEmu;
+ }
+
public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) {
gear1 = g1;
gear2 = g2;
@@ -91,8 +108,31 @@ public class GearsES1 implements GLEventListener {
// drawable.setGL(new DebugGL(drawable.getGL()));
GL _gl = drawable.getGL();
- // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/);
- GL2ES1 gl = _gl.getGL2ES1();
+
+ if(debugFFPEmu) {
+ // Debug ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
+ debug = false;
+ }
+ if(traceFFPEmu) {
+ // Trace ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) );
+ trace = false;
+ }
+ GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
+
+ if(debug) {
+ try {
+ // Debug ..
+ gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) );
+ } catch (Exception e) {e.printStackTrace();}
+ }
+ if(trace) {
+ try {
+ // Trace ..
+ gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) );
+ } catch (Exception e) {e.printStackTrace();}
+ }
System.err.println("GearsES1 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
index 84234d464..37ed83eb6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
@@ -10,11 +10,14 @@ import com.jogamp.opengl.util.glsl.fixedfunc.*;
public class RedSquareES1 implements GLEventListener {
- public static boolean glDebugEmu = false;
- public static boolean glDebug = false ;
- public static boolean glTrace = false ;
public static boolean oneThread = false;
public static boolean useAnimator = false;
+ private boolean debugFFPEmu = false;
+ private boolean verboseFFPEmu = false;
+ private boolean traceFFPEmu = false;
+ private boolean forceFFPEmu = false;
+ private boolean debug = false ;
+ private boolean trace = false ;
private int swapInterval = 0;
long startTime = 0;
@@ -28,6 +31,13 @@ public class RedSquareES1 implements GLEventListener {
this.swapInterval = 1;
}
+ public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
+ this.forceFFPEmu = forceFFPEmu;
+ this.verboseFFPEmu = verboseFFPEmu;
+ this.debugFFPEmu = debugFFPEmu;
+ this.traceFFPEmu = traceFFPEmu;
+ }
+
// FIXME: we must add storage of the pointers in the GL state to
// the GLImpl classes. The need for this can be seen by making
// these variables method local instead of instance members. The
@@ -42,29 +52,25 @@ public class RedSquareES1 implements GLEventListener {
System.err.println(Thread.currentThread()+" RedSquareES1.init ...");
GL _gl = drawable.getGL();
- if(glDebugEmu) {
- try {
- // Debug ..
- _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
-
- if(glTrace) {
- // Trace ..
- _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) );
- }
- } catch (Exception e) {e.printStackTrace();}
- glDebug = false;
- glTrace = false;
+ if(debugFFPEmu) {
+ // Debug ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
+ debug = false;
}
-
- GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl);
- if(glDebug) {
+ if(traceFFPEmu) {
+ // Trace ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) );
+ trace = false;
+ }
+ GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
+
+ if(debug) {
try {
// Debug ..
gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) );
} catch (Exception e) {e.printStackTrace();}
}
-
- if(glTrace) {
+ if(trace) {
try {
// Trace ..
gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) );
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
index ff168d9e9..9e0bbae71 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
@@ -48,6 +48,8 @@ import org.junit.Test;
public class TestGearsES1NEWT extends UITestCase {
static int width, height;
+ static boolean forceES2 = false;
+ static boolean forceFFPEmu = false;
@BeforeClass
public static void initClass() {
@@ -59,12 +61,16 @@ public class TestGearsES1NEWT extends UITestCase {
public static void releaseClass() {
}
- protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ protected void runTestGL(GLCapabilities caps, boolean forceFFPEmu) throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test");
- glWindow.addGLEventListener(new GearsES1());
+ final GearsES1 demo = new GearsES1();
+ demo.setForceFFPEmu(forceFFPEmu, forceFFPEmu, false, false);
+ glWindow.addGLEventListener(demo);
+ final SnapshotGLEventListener snap = new SnapshotGLEventListener();
+ glWindow.addGLEventListener(snap);
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -95,6 +101,7 @@ public class TestGearsES1NEWT extends UITestCase {
glWindow.setVisible(true);
animator.setUpdateFPSFrames(1, null);
animator.start();
+ snap.setMakeSnapshot();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
@@ -105,13 +112,13 @@ public class TestGearsES1NEWT extends UITestCase {
}
@Test
- public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
- runTestGL(caps);
+ public void test00() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES1());
+ runTestGL(caps, forceFFPEmu);
}
-
- static long duration = 500; // ms
-
+
+ static long duration = 1000; // ms
+
public static void main(String args[]) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -119,6 +126,10 @@ public class TestGearsES1NEWT extends UITestCase {
try {
duration = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-ffpemu")) {
+ forceFFPEmu = true;
}
}
org.junit.runner.JUnitCore.main(TestGearsES1NEWT.class.getName());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
index c327a3005..b0e6b2b00 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
@@ -48,6 +48,8 @@ import org.junit.Test;
public class TestRedSquareES1NEWT extends UITestCase {
static int width, height;
+ static boolean forceES2 = false;
+ static boolean forceFFPEmu = false;
@BeforeClass
public static void initClass() {
@@ -59,12 +61,16 @@ public class TestRedSquareES1NEWT extends UITestCase {
public static void releaseClass() {
}
- protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ protected void runTestGL(GLCapabilities caps, boolean forceFFPEmu) throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test");
- glWindow.addGLEventListener(new RedSquareES1());
+ final RedSquareES1 demo = new RedSquareES1();
+ demo.setForceFFPEmu(forceFFPEmu, forceFFPEmu, false, false);
+ glWindow.addGLEventListener(demo);
+ final SnapshotGLEventListener snap = new SnapshotGLEventListener();
+ glWindow.addGLEventListener(snap);
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -95,6 +101,7 @@ public class TestRedSquareES1NEWT extends UITestCase {
glWindow.setVisible(true);
animator.setUpdateFPSFrames(1, null);
animator.start();
+ snap.setMakeSnapshot();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
@@ -105,20 +112,24 @@ public class TestRedSquareES1NEWT extends UITestCase {
}
@Test
- public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
- runTestGL(caps);
+ public void test00() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES1());
+ runTestGL(caps, forceFFPEmu);
}
+
+ static long duration = 1000; // ms
- static long duration = 500; // ms
-
- public static void main(String args[]) {
+ public static void main(String args[]) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
try {
duration = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-ffpemu")) {
+ forceFFPEmu = true;
}
}
org.junit.runner.JUnitCore.main(TestRedSquareES1NEWT.class.getName());
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
new file mode 100644
index 000000000..276fb17f9
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java
@@ -0,0 +1,97 @@
+package com.jogamp.opengl.test.junit.jogl.util;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLPipelineFactory;
+import javax.media.opengl.glu.GLU;
+import javax.media.opengl.glu.gl2es1.GLUgl2es1;
+
+import com.jogamp.opengl.util.ImmModeSink;
+import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
+import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
+
+class DemoGL2ES1ImmModeSink implements GLEventListener {
+ private boolean debugFFPEmu = false;
+ private boolean verboseFFPEmu = false;
+ private boolean traceFFPEmu = false;
+ private boolean forceFFPEmu = false;
+ final ImmModeSink ims;
+ final GLU glu;
+
+ DemoGL2ES1ImmModeSink(boolean useVBO) {
+ ims = ImmModeSink.createFixed(3*3,
+ 3, GL.GL_FLOAT, // vertex
+ 3, GL.GL_FLOAT, // color
+ 0, GL.GL_FLOAT, // normal
+ 0, GL.GL_FLOAT, // texCoords
+ useVBO ? GL.GL_STATIC_DRAW : 0);
+ glu = new GLUgl2es1();
+ }
+
+ public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
+ this.forceFFPEmu = forceFFPEmu;
+ this.verboseFFPEmu = verboseFFPEmu;
+ this.debugFFPEmu = debugFFPEmu;
+ this.traceFFPEmu = traceFFPEmu;
+ }
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ GL _gl = drawable.getGL();
+ if(debugFFPEmu) {
+ // Debug ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
+ }
+ if(traceFFPEmu) {
+ // Trace ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) );
+ }
+ GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
+
+ 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));
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glMatrixMode( GL2ES1.GL_PROJECTION );
+ gl.glLoadIdentity();
+
+ // coordinate system origin at lower left with width and height same as the window
+ glu.gluOrtho2D( 0.0f, width, 0.0f, height );
+
+ gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
+ gl.glLoadIdentity();
+
+ gl.glViewport( 0, 0, width, height );
+ }
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ 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.glColor3f( 0, 0, 1 );
+ ims.glVertex2f( TestImmModeSinkES1NEWT.iWidth / 2, TestImmModeSinkES1NEWT.iHeight );
+ ims.glEnd(gl, true);
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..b66a0955c
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java
@@ -0,0 +1,161 @@
+package com.jogamp.opengl.test.junit.jogl.util;
+
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.fixedfunc.GLPointerFunc;
+import javax.media.opengl.glu.GLU;
+import javax.media.opengl.glu.gl2es1.GLUgl2es1;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.util.GLArrayDataWrapper;
+import com.jogamp.opengl.util.GLBuffers;
+
+class DemoGL2ES1Plain implements GLEventListener {
+ final boolean useArrayData;
+ final boolean useVBO;
+ final GLU glu;
+
+ final float[] vertices = new float[] { 0, 0, 0,
+ TestImmModeSinkES1NEWT.iWidth, 0, 0,
+ TestImmModeSinkES1NEWT.iWidth / 2, TestImmModeSinkES1NEWT.iHeight, 0 };
+
+ final float[] colors = new float[] { 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1 };
+
+ final ByteBuffer bufferAll;
+ final int bufferVOffset, bufferCOffset;
+ final int bufferVSize, bufferCSize;
+ final FloatBuffer bufferC, bufferV;
+ final int[] vboName = new int[] { 0 };
+ final GLArrayDataWrapper arrayC, arrayV;
+
+ DemoGL2ES1Plain(boolean useArrayData, boolean useVBO) {
+ this.useArrayData = useArrayData;
+ this.useVBO = useVBO;
+ this.glu = new GLUgl2es1();
+
+ bufferAll = Buffers.newDirectByteBuffer( ( colors.length + vertices.length ) * Buffers.SIZEOF_FLOAT );
+
+ bufferVOffset = 0;
+ bufferVSize = 3*3*GLBuffers.sizeOfGLType(GL.GL_FLOAT);
+ bufferCOffset = bufferVSize;
+ bufferCSize = 3*3*GLBuffers.sizeOfGLType(GL.GL_FLOAT);
+
+ bufferV = (FloatBuffer) GLBuffers.sliceGLBuffer(bufferAll, bufferVOffset, bufferVSize, GL.GL_FLOAT);
+ bufferV.put(vertices, 0, vertices.length).rewind();
+ bufferC = (FloatBuffer) GLBuffers.sliceGLBuffer(bufferAll, bufferCOffset, bufferCSize, GL.GL_FLOAT);
+ bufferC.put(colors, 0, colors.length).rewind();
+
+ System.err.println("bufferAll: "+bufferAll+", byteOffset "+Buffers.getDirectBufferByteOffset(bufferAll));
+ System.err.println("bufferV: off "+bufferVOffset+", size "+bufferVSize+": "+bufferV+", byteOffset "+Buffers.getDirectBufferByteOffset(bufferV));
+ System.err.println("bufferC: off "+bufferCOffset+", size "+bufferCSize+": "+bufferC+", byteOffset "+Buffers.getDirectBufferByteOffset(bufferC));
+
+ if(useArrayData) {
+ arrayV = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, 3, GL.GL_FLOAT, false, 0,
+ bufferV, 0, bufferVOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
+
+ arrayC = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, 3, GL.GL_FLOAT, false, 0,
+ bufferC, 0, bufferCOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
+ } else {
+ arrayV = null;
+ arrayC = null;
+ }
+ }
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ 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));
+ if(useVBO) {
+ gl.glGenBuffers(1, vboName, 0);
+ if(0 == vboName[0]) {
+ throw new GLException("glGenBuffers didn't return valid VBO name");
+ }
+ }
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glMatrixMode( GL2ES1.GL_PROJECTION );
+ gl.glLoadIdentity();
+
+ // coordinate system origin at lower left with width and height same as the window
+ glu.gluOrtho2D( 0.0f, width, 0.0f, height );
+
+ gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
+ gl.glLoadIdentity();
+
+ gl.glViewport( 0, 0, width, height );
+ }
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glClear( GL.GL_COLOR_BUFFER_BIT );
+
+ // draw a triangle filling the window
+ gl.glLoadIdentity();
+
+ if(useVBO) {
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName[0]);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, bufferAll.limit(), bufferAll, GL.GL_STATIC_DRAW);
+ if(useArrayData) {
+ arrayV.setVBOName(vboName[0]);
+ arrayC.setVBOName(vboName[0]);
+ }
+ }
+
+ gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
+ if(useArrayData) {
+ gl.glVertexPointer(arrayV);
+ } else {
+ if(useVBO) {
+ gl.glVertexPointer(3, GL.GL_FLOAT, 0, bufferVOffset);
+ } else {
+ gl.glVertexPointer(3, GL.GL_FLOAT, 0, bufferV);
+ }
+ }
+
+ gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
+ if(useArrayData) {
+ gl.glColorPointer(arrayC);
+ } else {
+ if(useVBO) {
+ gl.glColorPointer(3, GL.GL_FLOAT, 0, bufferCOffset);
+ } else {
+ gl.glColorPointer(3, GL.GL_FLOAT, 0, bufferC);
+ }
+ }
+
+ if(useVBO) {
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
+ }
+
+ gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);
+ gl.glFlush();
+
+ gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
+ gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ if(0 != vboName[0]) {
+ gl.glDeleteBuffers(1, vboName, 0);
+ vboName[0] = 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java
new file mode 100644
index 000000000..75a98ed1e
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java
@@ -0,0 +1,142 @@
+/**
+ * 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.InputStream;
+import java.net.URLConnection;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.util.ImmModeSink;
+import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
+import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLPipelineFactory;
+import javax.media.opengl.glu.GLU;
+
+public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDraw01Accessor {
+ private boolean debugFFPEmu = false;
+ private boolean verboseFFPEmu = false;
+ private boolean traceFFPEmu = false;
+ private boolean forceFFPEmu = false;
+ private ImmModeSink ims;
+ private GLU glu = new GLU();
+ private TextureData textureData;
+ private Texture texture;
+
+ public DemoGL2ES1TextureImmModeSink() {
+ this.ims = ImmModeSink.createFixed(32, 3, GL.GL_FLOAT, 4, GL.GL_FLOAT, 0, GL.GL_FLOAT, 2, GL.GL_FLOAT, GL.GL_STATIC_DRAW);
+ }
+
+ public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
+ this.forceFFPEmu = forceFFPEmu;
+ this.verboseFFPEmu = verboseFFPEmu;
+ this.debugFFPEmu = debugFFPEmu;
+ this.traceFFPEmu = traceFFPEmu;
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ GL _gl = drawable.getGL();
+ if(debugFFPEmu) {
+ // Debug ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
+ }
+ if(traceFFPEmu) {
+ // Trace ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) );
+ }
+ GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
+
+ URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
+ try {
+ InputStream testTextureStream = testTextureUrlConn.getInputStream();
+ textureData = TextureIO.newTextureData(gl.getGLProfile(), testTextureStream , false /* mipmap */, TextureIO.PNG);
+ texture = TextureIO.newTexture(gl, textureData);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Texture getTexture( ) {
+ return this.texture;
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+ 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) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+ if(null!=texture) {
+ texture.disable(gl);
+ texture.destroy(gl);
+ }
+ if(null!=textureData) {
+ textureData.destroy();
+ }
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ // draw one quad with the texture
+ if(null!=texture) {
+ texture.enable(gl);
+ texture.bind(gl);
+ // gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
+ TextureCoords coords = texture.getImageTexCoords();
+ ims.glBegin(ImmModeSink.GL_QUADS);
+ ims.glTexCoord2f(coords.left(), coords.bottom());
+ ims.glVertex3f(0, 0, 0);
+ ims.glTexCoord2f(coords.right(), coords.bottom());
+ ims.glVertex3f(1, 0, 0);
+ ims.glTexCoord2f(coords.right(), coords.top());
+ ims.glVertex3f(1, 1, 0);
+ ims.glTexCoord2f(coords.left(), coords.top());
+ ims.glVertex3f(0, 1, 0);
+ ims.glEnd(gl);
+ texture.disable(gl);
+ }
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestES1FixedFunctionPipelineNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestES1FixedFunctionPipelineNEWT.java
new file mode 100644
index 000000000..9d84bc58c
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestES1FixedFunctionPipelineNEWT.java
@@ -0,0 +1,151 @@
+/**
+ * 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.util;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
+
+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 TestES1FixedFunctionPipelineNEWT extends UITestCase {
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ width = 512;
+ height = 512;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL0(GLCapabilities caps, GLEventListener demo) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setTitle(getSimpleTestName("."));
+
+ glWindow.addGLEventListener(demo);
+ final SnapshotGLEventListener snap = new SnapshotGLEventListener();
+ snap.setPostSNDetail(demo.getClass().getSimpleName());
+ glWindow.addGLEventListener(snap);
+
+ Animator animator = new Animator(glWindow);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+
+ glWindow.setSize(width, height);
+ glWindow.setVisible(true);
+ animator.setUpdateFPSFrames(1, null);
+ animator.start();
+
+ snap.setMakeSnapshot();
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+ glWindow.removeGLEventListener(demo);
+
+ animator.stop();
+ glWindow.destroy();
+ }
+
+ protected void runTestGL(GLCapabilities caps, boolean forceFFPEmu) throws InterruptedException {
+ final RedSquareES1 demo01 = new RedSquareES1();
+ demo01.setForceFFPEmu(forceFFPEmu, false, false, false);
+ runTestGL0(caps, demo01);
+
+ final GearsES1 demo02 = new GearsES1();
+ demo02.setForceFFPEmu(forceFFPEmu, false, false, false);
+ runTestGL0(caps, demo02);
+
+ final DemoGL2ES1ImmModeSink demo03 = new DemoGL2ES1ImmModeSink(true);
+ demo03.setForceFFPEmu(forceFFPEmu, false, false, false);
+ runTestGL0(caps, demo03);
+
+ final DemoGL2ES1TextureImmModeSink demo04 = new DemoGL2ES1TextureImmModeSink();
+ demo04.setForceFFPEmu(forceFFPEmu, false, false, false);
+ runTestGL0(caps, demo04);
+ }
+
+ @Test
+ public void test01GL2Normal() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ runTestGL(caps, false);
+ }
+
+ @Test
+ public void test03GL2FFPEmu() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ runTestGL(caps, true);
+ }
+
+ @Test
+ public void test04GL2ES1Normal() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2ES1)) { System.err.println("GL2ES1 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES1));
+ runTestGL(caps, false);
+ }
+
+ @Test
+ public void test05ES2FFPEmu() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ runTestGL(caps, false); // should be FFPEmu implicit
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestES1FixedFunctionPipelineNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES1NEWT.java
index 05f78bc60..d8bdf8ab2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestImmModeSinkES1NEWT.java
@@ -29,30 +29,17 @@
package com.jogamp.opengl.test.junit.jogl.util;
import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.fixedfunc.GLPointerFunc;
-import javax.media.opengl.glu.GLU;
-import javax.media.opengl.glu.gl2es1.GLUgl2es1;
import org.junit.Test;
-import com.jogamp.common.nio.Buffers;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.util.GLArrayDataWrapper;
-import com.jogamp.opengl.util.GLBuffers;
-import com.jogamp.opengl.util.ImmModeSink;
/**
* Testing the ImmModeSink w/ GL2ES1 context
@@ -92,212 +79,6 @@ public class TestImmModeSinkES1NEWT extends UITestCase {
glad.destroy();
}
- static class DemoGL2ES1Plain implements GLEventListener {
- final boolean useArrayData;
- final boolean useVBO;
- final GLU glu;
-
- final float[] vertices = new float[] { 0, 0, 0,
- iWidth, 0, 0,
- iWidth / 2, iHeight, 0 };
-
- final float[] colors = new float[] { 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1 };
-
- final ByteBuffer bufferAll;
- final int bufferVOffset, bufferCOffset;
- final int bufferVSize, bufferCSize;
- final FloatBuffer bufferC, bufferV;
- final int[] vboName = new int[] { 0 };
- final GLArrayDataWrapper arrayC, arrayV;
-
- DemoGL2ES1Plain(boolean useArrayData, boolean useVBO) {
- this.useArrayData = useArrayData;
- this.useVBO = useVBO;
- this.glu = new GLUgl2es1();
-
- bufferAll = Buffers.newDirectByteBuffer( ( colors.length + vertices.length ) * Buffers.SIZEOF_FLOAT );
-
- bufferVOffset = 0;
- bufferVSize = 3*3*GLBuffers.sizeOfGLType(GL.GL_FLOAT);
- bufferCOffset = bufferVSize;
- bufferCSize = 3*3*GLBuffers.sizeOfGLType(GL.GL_FLOAT);
-
- bufferV = (FloatBuffer) GLBuffers.sliceGLBuffer(bufferAll, bufferVOffset, bufferVSize, GL.GL_FLOAT);
- bufferV.put(vertices, 0, vertices.length).rewind();
- bufferC = (FloatBuffer) GLBuffers.sliceGLBuffer(bufferAll, bufferCOffset, bufferCSize, GL.GL_FLOAT);
- bufferC.put(colors, 0, colors.length).rewind();
-
- System.err.println("bufferAll: "+bufferAll+", byteOffset "+Buffers.getDirectBufferByteOffset(bufferAll));
- System.err.println("bufferV: off "+bufferVOffset+", size "+bufferVSize+": "+bufferV+", byteOffset "+Buffers.getDirectBufferByteOffset(bufferV));
- System.err.println("bufferC: off "+bufferCOffset+", size "+bufferCSize+": "+bufferC+", byteOffset "+Buffers.getDirectBufferByteOffset(bufferC));
-
- if(useArrayData) {
- arrayV = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, 3, GL.GL_FLOAT, false, 0,
- bufferV, 0, bufferVOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
-
- arrayC = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, 3, GL.GL_FLOAT, false, 0,
- bufferC, 0, bufferCOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
- } else {
- arrayV = null;
- arrayC = null;
- }
- }
-
- @Override
- public void init(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- 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));
- if(useVBO) {
- gl.glGenBuffers(1, vboName, 0);
- if(0 == vboName[0]) {
- throw new GLException("glGenBuffers didn't return valid VBO name");
- }
- }
- }
-
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.glMatrixMode( GL2ES1.GL_PROJECTION );
- gl.glLoadIdentity();
-
- // coordinate system origin at lower left with width and height same as the window
- glu.gluOrtho2D( 0.0f, width, 0.0f, height );
-
- gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
- gl.glLoadIdentity();
-
- gl.glViewport( 0, 0, width, height );
- }
-
- @Override
- public void display(GLAutoDrawable drawable) {
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.glClear( GL.GL_COLOR_BUFFER_BIT );
-
- // draw a triangle filling the window
- gl.glLoadIdentity();
-
- if(useVBO) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName[0]);
- gl.glBufferData(GL.GL_ARRAY_BUFFER, bufferAll.limit(), bufferAll, GL.GL_STATIC_DRAW);
- if(useArrayData) {
- arrayV.setVBOName(vboName[0]);
- arrayC.setVBOName(vboName[0]);
- }
- }
-
- gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
- if(useArrayData) {
- gl.glVertexPointer(arrayV);
- } else {
- if(useVBO) {
- gl.glVertexPointer(3, GL.GL_FLOAT, 0, bufferVOffset);
- } else {
- gl.glVertexPointer(3, GL.GL_FLOAT, 0, bufferV);
- }
- }
-
- gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
- if(useArrayData) {
- gl.glColorPointer(arrayC);
- } else {
- if(useVBO) {
- gl.glColorPointer(3, GL.GL_FLOAT, 0, bufferCOffset);
- } else {
- gl.glColorPointer(3, GL.GL_FLOAT, 0, bufferC);
- }
- }
-
- if(useVBO) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
- }
-
- gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);
- gl.glFlush();
-
- gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
- gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
- }
-
- @Override
- public void dispose(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- if(0 != vboName[0]) {
- gl.glDeleteBuffers(1, vboName, 0);
- vboName[0] = 0;
- }
- }
- }
-
- static class DemoGL2ES1ImmModeSink implements GLEventListener {
- final ImmModeSink ims;
- final GLU glu;
-
- DemoGL2ES1ImmModeSink(boolean useVBO) {
- ims = ImmModeSink.createFixed(3*3,
- 3, GL.GL_FLOAT, // vertex
- 3, GL.GL_FLOAT, // color
- 0, GL.GL_FLOAT, // normal
- 0, GL.GL_FLOAT, // texCoords
- useVBO ? GL.GL_STATIC_DRAW : 0);
- glu = new GLUgl2es1();
- }
-
- @Override
- public void init(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- 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));
- }
-
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.glMatrixMode( GL2ES1.GL_PROJECTION );
- gl.glLoadIdentity();
-
- // coordinate system origin at lower left with width and height same as the window
- glu.gluOrtho2D( 0.0f, width, 0.0f, height );
-
- gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
- gl.glLoadIdentity();
-
- gl.glViewport( 0, 0, width, height );
- }
-
- @Override
- public void display(GLAutoDrawable drawable) {
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- 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( iWidth, 0 );
- ims.glColor3f( 0, 0, 1 );
- ims.glVertex2f( iWidth / 2, iHeight );
- ims.glEnd(gl, true);
- }
-
- @Override
- public void dispose(GLAutoDrawable drawable) {
- }
- }
-
@Test
public void test01Plain__GL2ES1_VBOOffUsePlain() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
@@ -340,6 +121,13 @@ public class TestImmModeSinkES1NEWT extends UITestCase {
doTest(reqGLCaps, new DemoGL2ES1ImmModeSink(true));
}
+ @Test
+ public void test07ImmSinkGL2ES1_VBOOnTexture() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new DemoGL2ES1TextureImmModeSink());
+ }
+
public static void main(String args[]) throws IOException {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
index ccfd3867e..b028df377 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
@@ -217,6 +217,7 @@ public abstract class UITestCase {
private volatile boolean verbose = false;
private volatile int displayCount=0;
private volatile int reshapeCount=0;
+ private volatile String postSNDetail = null;
public SnapshotGLEventListener(GLReadBufferUtil screenshot) {
this.screenshot = screenshot;
}
@@ -236,7 +237,7 @@ public abstract class UITestCase {
}
if(_makeShot) {
makeShot=false;
- snapshot(displayCount, null, gl, screenshot, TextureIO.PNG, null);
+ snapshot(displayCount, postSNDetail, gl, screenshot, TextureIO.PNG, null);
}
displayCount++;
}
@@ -255,6 +256,9 @@ public abstract class UITestCase {
public void setVerbose(boolean v) {
verbose=v;
}
+ public void setPostSNDetail(String v) {
+ postSNDetail = v;
+ }
};
}