summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-24 02:40:10 +0100
committerSven Gothel <[email protected]>2012-02-24 02:40:10 +0100
commit5940f88b19a375bd20432be01bde02cda065fbce (patch)
treeff3b7cdc7522a23ccbbd389a74faf2ceccf62fb7 /src/test/com/jogamp/opengl
parent29ee4fa97a7e17fe2eb07797350200300d8126d7 (diff)
Fix MultisampleDemo01 -> MultisampleDemoES1 (proper profile, remove immediate mode for ES1) ; Fix GLES1Impl.glOrtho()
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemoES1.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java)54
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleAWT.java)10
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleNEWT.java)19
3 files changed, 52 insertions, 31 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemoES1.java
index ab0171cb8..0aaf4b020 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemoES1.java
@@ -45,29 +45,33 @@ import jogamp.opengl.x11.glx.X11GLXGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GL;
-import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLPipelineFactory;
-class MultisampleDemo01 implements GLEventListener {
+import com.jogamp.opengl.util.ImmModeSink;
+
+class MultisampleDemoES1 implements GLEventListener {
static boolean glDebug = false;
static boolean glTrace = false;
boolean multisample;
+ ImmModeSink immModeSink;
- public MultisampleDemo01(boolean multisample) {
+ public MultisampleDemoES1(boolean multisample) {
this.multisample = multisample;
}
public void init(GLAutoDrawable drawable) {
- AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
System.err.println();
- System.err.println("Info: " + config);
+ System.err.println("Requested: " + drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities());
+ System.err.println();
+ System.err.println("Chosen : " + drawable.getChosenGLCapabilities());
System.err.println();
- if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) {
+ if (!drawable.getGL().isGLES() && NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) {
+ AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
X11GLXGraphicsConfiguration x11config = (X11GLXGraphicsConfiguration) config;
long display = drawable.getNativeSurface().getDisplayHandle();
int[] foo = new int[1];
@@ -80,16 +84,16 @@ class MultisampleDemo01 implements GLEventListener {
if (glDebug) {
try {
// Debug ..
- _gl = _gl.getContext().setGL(GLPipelineFactory.create("javax.media.opengl.Debug", GL2.class, _gl, null));
+ _gl = _gl.getContext().setGL(GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, _gl, null));
if (glTrace) {
// Trace ..
- _gl = _gl.getContext().setGL(GLPipelineFactory.create("javax.media.opengl.Trace", GL2.class, _gl, new Object[]{System.err}));
+ _gl = _gl.getContext().setGL(GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, _gl, new Object[]{System.err}));
}
} catch (Exception e) {
e.printStackTrace();
}
}
- GL2 gl = _gl.getGL2();
+ GL2ES1 gl = _gl.getGL2ES1();
if (multisample) {
gl.glEnable(GL.GL_MULTISAMPLE);
}
@@ -104,26 +108,38 @@ class MultisampleDemo01 implements GLEventListener {
if (multisample) {
gl.glDisable(GL.GL_MULTISAMPLE);
}
+ immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 40,
+ 3, GL.GL_FLOAT, // vertex
+ 0, GL.GL_FLOAT, // color
+ 0, GL.GL_FLOAT,// normal
+ 0, GL.GL_FLOAT); // texture
+ final int numSteps = 20;
+ final double increment = Math.PI / numSteps;
+ final double radius = 1;
+ immModeSink.glBegin(GL.GL_LINES);
+ for (int i = numSteps - 1; i >= 0; i--) {
+ immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)),
+ (float) (radius * Math.sin(i * increment)),
+ 0f);
+ immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)),
+ (float) (-1.0 * radius * Math.sin(i * increment)),
+ 0f);
+ }
+ immModeSink.glEnd(gl, false);
}
public void dispose(GLAutoDrawable drawable) {
+ immModeSink.destroy(drawable.getGL());
+ immModeSink = null;
}
public void display(GLAutoDrawable drawable) {
- GL2 gl = drawable.getGL().getGL2();
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
if (multisample) {
gl.glEnable(GL.GL_MULTISAMPLE);
}
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- int numSteps = 20;
- double increment = Math.PI / numSteps;
- double radius = 1;
- gl.glBegin(GL.GL_LINES);
- for (int i = numSteps - 1; i >= 0; i--) {
- gl.glVertex3d(radius * Math.cos(i * increment), radius * Math.sin(i * increment), 0);
- gl.glVertex3d(-1.0 * radius * Math.cos(i * increment), -1.0 * radius * Math.sin(i * increment), 0);
- }
- gl.glEnd();
+ immModeSink.draw(gl, true);
if (multisample) {
gl.glDisable(GL.GL_MULTISAMPLE);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
index 786fd608b..517d12578 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
@@ -46,6 +46,7 @@ import java.awt.Frame;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.test.junit.util.MiscUtils;
@@ -54,7 +55,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import org.junit.Test;
-public class TestMultisampleAWT extends UITestCase {
+public class TestMultisampleES1AWT extends UITestCase {
static long durationPerTest = 250; // ms
private GLCanvas canvas;
@@ -65,7 +66,7 @@ public class TestMultisampleAWT extends UITestCase {
}
}
System.out.println("durationPerTest: "+durationPerTest);
- String tstname = TestMultisampleAWT.class.getName();
+ String tstname = TestMultisampleES1AWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
@@ -80,7 +81,8 @@ public class TestMultisampleAWT extends UITestCase {
}
private void testMultiSampleAAImpl(int samples) throws InterruptedException, InvocationTargetException {
- GLCapabilities caps = new GLCapabilities(null);
+ GLProfile glp = GLProfile.getMaxFixedFunc(true);
+ GLCapabilities caps = new GLCapabilities(glp);
GLCapabilitiesChooser chooser = new MultisampleChooser01();
if(samples>0) {
@@ -92,7 +94,7 @@ public class TestMultisampleAWT extends UITestCase {
}
canvas = new GLCanvas(caps, chooser, null, null);
- canvas.addGLEventListener(new MultisampleDemo01(samples>0?true:false));
+ canvas.addGLEventListener(new MultisampleDemoES1(samples>0?true:false));
final Frame frame = new Frame("Multi Samples "+samples);
frame.setLayout(new BorderLayout());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
index 1e3274dbb..cdfeb2bad 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
@@ -40,12 +40,16 @@
package com.jogamp.opengl.test.junit.jogl.caps;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Test;
+
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
-import javax.media.opengl.*;
-import org.junit.Test;
-public class TestMultisampleNEWT {
+public class TestMultisampleES1NEWT {
static long durationPerTest = 500; // ms
private GLWindow window;
@@ -56,7 +60,7 @@ public class TestMultisampleNEWT {
}
}
System.out.println("durationPerTest: "+durationPerTest);
- String tstname = TestMultisampleNEWT.class.getName();
+ String tstname = TestMultisampleES1NEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
@@ -71,7 +75,8 @@ public class TestMultisampleNEWT {
}
private void testMultiSampleAAImpl(int samples) throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(null);
+ GLProfile glp = GLProfile.getMaxFixedFunc(true);
+ GLCapabilities caps = new GLCapabilities(glp);
GLCapabilitiesChooser chooser = new MultisampleChooser01();
if(samples>0) {
@@ -85,14 +90,12 @@ public class TestMultisampleNEWT {
window = GLWindow.create(caps);
window.setCapabilitiesChooser(chooser);
- window.addGLEventListener(new MultisampleDemo01(samples>0?true:false));
+ window.addGLEventListener(new MultisampleDemoES1(samples>0?true:false));
window.setSize(512, 512);
window.setVisible(true);
window.setPosition(0, 0);
window.requestFocus();
- GLCapabilitiesImmutable capsChosen0 = window.getChosenGLCapabilities();
-
Thread.sleep(durationPerTest);
window.destroy();