diff options
Diffstat (limited to 'src/test/com/jogamp/opengl')
7 files changed, 108 insertions, 52 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java index 8f03af7c9..5a5f9debb 100755 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java @@ -2,7 +2,6 @@ package com.jogamp.opengl.test.junit.graph; import java.io.IOException;
-import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
@@ -12,7 +11,6 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.graph.curve.Region;
@@ -29,12 +27,32 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class TestTextRendererNEWT01 extends UITestCase {
static final boolean DEBUG = false;
static final boolean TRACE = false;
+ static long duration = 100; // ms
+ static int atoi(String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (Exception ex) { throw new RuntimeException(ex); }
+ }
+
public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = atoi(args[i]);
+ }
+ }
String tstname = TestTextRendererNEWT01.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
+ static void sleep() {
+ try {
+ System.err.println("** new frame ** (sleep: "+duration+"ms)");
+ Thread.sleep(duration);
+ } catch (InterruptedException ie) {}
+ }
+
static void destroyWindow(GLWindow window) {
if(null!=window) {
window.destroy();
@@ -60,32 +78,44 @@ public class TestTextRendererNEWT01 extends UITestCase { GLCapabilities caps = new GLCapabilities(glp);
caps.setAlphaBits(4);
+ System.err.println("Requested: "+caps);
GLWindow window = createWindow("text-vbaa1-msaa0", caps, 800,400);
+ window.display();
+ System.err.println("Chosen: "+window.getChosenGLCapabilities());
+
RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
TextGLListener textGLListener = new TextGLListener(rs, Region.VBAA_RENDERING_BIT, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
- textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0);
- textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
- window.display();
-
- textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
- window.display();
-
- textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
- window.display();
+ if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
+ window.display();
+ sleep();
+ }
- textGLListener.setFontSet(FontFactory.JAVA, 0, 0);
- textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
- window.display();
-
- textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
- window.display();
-
- textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
- window.display();
+ if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
+ window.display();
+ sleep();
+ }
destroyWindow(window);
}
@@ -97,32 +127,44 @@ public class TestTextRendererNEWT01 extends UITestCase { caps.setAlphaBits(4);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
+ System.err.println("Requested: "+caps);
GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
+ window.display();
+ System.err.println("Chosen: "+window.getChosenGLCapabilities());
+
RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
TextGLListener textGLListener = new TextGLListener(rs, 0, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
- textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0);
- textGLListener.setTech(-400, -30, 0f, -1000, 0);
- window.display();
-
- textGLListener.setTech(-400, -30, 0, -380, 0);
- window.display();
-
- textGLListener.setTech(-400, -20, 0, -80, 0);
- window.display();
-
- textGLListener.setFontSet(FontFactory.JAVA, 0, 0);
- textGLListener.setTech(-400, -30, 0f, -1000, 0);
- window.display();
-
- textGLListener.setTech(-400, -30, 0, -380, 0);
- window.display();
-
- textGLListener.setTech(-400, -20, 0, -80, 0);
- window.display();
+ if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, 0);
+ window.display();
+ sleep();
+ }
+
+ if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, 0);
+ window.display();
+ sleep();
+ }
destroyWindow(window);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java index b8bb9ac14..46557e8c8 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java @@ -102,7 +102,6 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { gl.glEnable(GL2ES2.GL_BLEND); regionRenderer.setAlpha(gl, 1.0f); regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - MSAATool.dump(drawable); createTestOutline(); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java index 904e54e8e..525c5e648 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java @@ -100,7 +100,6 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { gl.glEnable(GL2ES2.GL_BLEND); regionRenderer.setAlpha(gl, 1.0f); regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - MSAATool.dump(drawable); createTestOutline(); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index dac965df3..46085b179 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -121,6 +121,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } System.err.println("*** "+gl.getContext().getGLVersion()); System.err.println("*** GLDebugMessage "+gl.getContext().isGLDebugMessageEnabled()); + MSAATool.dump(drawable); gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); getRenderer().init(gl); } @@ -193,8 +194,9 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize, objName); final String filename = dir + tech + sw +".tga"; - screenshot.readPixels(drawable.getGL(), drawable, false); - screenshot.write(new File(filename)); + if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + screenshot.write(new File(filename)); + } } int screenshot_num = 0; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java index da34b1d78..5c7d15ad1 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java @@ -64,7 +64,6 @@ public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 { gl.glEnable(GL2ES2.GL_BLEND); textRenderer.setAlpha(gl, 1.0f); textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - MSAATool.dump(drawable); } public void dispose(GLAutoDrawable drawable) { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java index 1fbedb338..4cddb1340 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java @@ -27,12 +27,27 @@ */ package com.jogamp.opengl.test.junit.graph.demos; +import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilitiesImmutable; public class MSAATool { + public static boolean glIsEnabled(GL gl, int name) { + boolean isEnabled = false; + try { + isEnabled = gl.glIsEnabled(name); + int glerr = gl.glGetError(); + if(GL.GL_NO_ERROR != glerr) { + System.err.println("glIsEnabled(0x"+Integer.toHexString(name)+") -> error 0x"+Integer.toHexString(glerr)); + } + } catch (Exception e) { + System.err.println("Catched Exception: "+e.getMessage()); + // e.printStackTrace(); + } + return isEnabled; + } public static void dump(GLAutoDrawable drawable) { float[] vf = new float[] { 0f }; byte[] vb = new byte[] { 0 }; @@ -44,8 +59,7 @@ public class MSAATool { System.out.println(" Caps realised "+caps); System.out.println(" Caps sample buffers "+caps.getSampleBuffers()+", samples "+caps.getNumSamples()); - // default TRUE - System.out.println(" GL MULTISAMPLE "+gl.glIsEnabled(GL2ES2.GL_MULTISAMPLE)); + System.out.println(" GL MULTISAMPLE "+glIsEnabled(gl, GL2ES2.GL_MULTISAMPLE)); // sample buffers min 0, same as GLX_SAMPLE_BUFFERS_ARB or WGL_SAMPLE_BUFFERS_ARB gl.glGetIntegerv(GL2GL3.GL_SAMPLE_BUFFERS, vi, 0); // samples min 0 @@ -54,15 +68,15 @@ public class MSAATool { System.out.println("GL CSAA SETUP:"); // default FALSE - System.out.println(" GL SAMPLE COVERAGE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_COVERAGE)); + System.out.println(" GL SAMPLE COVERAGE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_COVERAGE)); // default FALSE - System.out.println(" GL SAMPLE_ALPHA_TO_COVERAGE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_ALPHA_TO_COVERAGE)); + System.out.println(" GL SAMPLE_ALPHA_TO_COVERAGE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_ALPHA_TO_COVERAGE)); // default FALSE - System.out.println(" GL SAMPLE_ALPHA_TO_ONE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE)); + System.out.println(" GL SAMPLE_ALPHA_TO_ONE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_ALPHA_TO_ONE)); // default FALSE, value 1, invert false gl.glGetFloatv(GL2GL3.GL_SAMPLE_COVERAGE_VALUE, vf, 0); gl.glGetBooleanv(GL2GL3.GL_SAMPLE_COVERAGE_INVERT, vb, 0); - System.out.println(" GL SAMPLE_COVERAGE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_COVERAGE) + + System.out.println(" GL SAMPLE_COVERAGE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_COVERAGE) + ": SAMPLE_COVERAGE_VALUE "+vf[0]+ ", SAMPLE_COVERAGE_INVERT "+vb[0]); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index 0fe48e550..d9d2dd95a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -180,8 +180,9 @@ public abstract class UIListenerBase01 implements GLEventListener { pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), 0, objName); final String filename = dir + tech + sw +".tga"; - screenshot.readPixels(drawable.getGL(), drawable, false); - screenshot.write(new File(filename)); + if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + screenshot.write(new File(filename)); + } } int screenshot_num = 0; |