summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java73
1 files changed, 34 insertions, 39 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
index 360f4e8d7..32bea649f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
@@ -29,7 +29,6 @@ package com.jogamp.opengl.test.junit.jogl.glsl;
import com.jogamp.common.nio.Buffers;
import com.jogamp.newt.MonitorDevice;
-import com.jogamp.newt.MonitorMode;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
@@ -43,7 +42,6 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.io.IOException;
import java.nio.FloatBuffer;
-import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLCapabilities;
@@ -73,9 +71,9 @@ public class TestRulerNEWT01 extends UITestCase {
System.err.println(winctx.context);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
- // test code ..
+ // test code ..
final ShaderState st = new ShaderState();
-
+
final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
"shader/bin", "default", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
@@ -85,50 +83,47 @@ public class TestRulerNEWT01 extends UITestCase {
final ShaderProgram sp0 = new ShaderProgram();
sp0.add(gl, vp0, System.err);
- sp0.add(gl, fp0, System.err);
- Assert.assertTrue(0 != sp0.program());
+ sp0.add(gl, fp0, System.err);
+ Assert.assertTrue(0 != sp0.program());
Assert.assertTrue(!sp0.inUse());
Assert.assertTrue(!sp0.linked());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
-
+
st.attachShaderProgram(gl, sp0, true);
-
+
final PMVMatrix pmvMatrix = new PMVMatrix();
final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
- st.ownUniform(pmvMatrixUniform);
+ st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
-
+
final GLUniformData rulerColor= new GLUniformData("gcu_RulerColor", 3, Buffers.newDirectFloatBuffer(3));
final FloatBuffer rulerColorV = (FloatBuffer) rulerColor.getBuffer();
rulerColorV.put(0, 0.5f);
rulerColorV.put(1, 0.5f);
rulerColorV.put(2, 0.5f);
- st.ownUniform(rulerColor);
- st.uniform(gl, rulerColor);
+ st.ownUniform(rulerColor);
+ st.uniform(gl, rulerColor);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
-
+
Assert.assertNotNull(winctx);
Assert.assertNotNull(winctx.window);
Assert.assertNotNull(winctx.window.getScreen());
- final MonitorDevice monitor = winctx.window.getMainMonitor();
- Assert.assertNotNull(monitor);
- System.err.println(monitor);
- final MonitorMode mmode = monitor.getCurrentMode();
- Assert.assertNotNull(mmode);
- System.err.println(mmode);
- final DimensionImmutable sdim = monitor.getSizeMM();
- final DimensionImmutable spix = mmode.getSurfaceSize().getResolution();
+ final float[] ppmmStore = { 0f, 0f };
+ {
+ final MonitorDevice monitor = winctx.window.getMainMonitor();
+ Assert.assertNotNull(monitor);
+ System.err.println(monitor);
+ monitor.getPixelsPerMM(ppmmStore);
+ }
final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2));
final FloatBuffer rulerPixFreqV = (FloatBuffer) rulerPixFreq.getBuffer();
- rulerPixFreqV.put(0, (float)spix.getWidth() / (float)sdim.getWidth() * 10.0f);
- rulerPixFreqV.put(1, (float)spix.getHeight() / (float)sdim.getHeight() * 10.0f);
+ rulerPixFreqV.put(0, ppmmStore[0] * 10.0f);
+ rulerPixFreqV.put(1, ppmmStore[1] * 10.0f);
st.ownUniform(rulerPixFreq);
- st.uniform(gl, rulerPixFreq);
+ st.uniform(gl, rulerPixFreq);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
- System.err.println("Screen dim "+sdim);
- System.err.println("Screen siz "+spix);
System.err.println("Screen pixel/cm "+rulerPixFreqV.get(0)+", "+rulerPixFreqV.get(1));
final GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("gca_Vertices", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
@@ -138,7 +133,7 @@ public class TestRulerNEWT01 extends UITestCase {
vertices0.putf(1); vertices0.putf(0); vertices0.putf(0);
vertices0.seal(gl, true);
st.ownAttribute(vertices0, true);
-
+
// misc GL setup
gl.glClearColor(1, 1, 1, 1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
@@ -154,29 +149,29 @@ public class TestRulerNEWT01 extends UITestCase {
// pmvMatrix.glTranslatef(0, 0, -6);
// pmvMatrix.glRotatef(45f, 1f, 0f, 0f);
st.uniform(gl, pmvMatrixUniform);
- gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
+ gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
-
+
for(int i=0; i<10; i++) {
vertices0.enableBuffer(gl, true);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
vertices0.enableBuffer(gl, false);
drawable.swapBuffers();
Thread.sleep(durationPerTest/10);
}
-
+
long t2 = System.nanoTime();
-
+
NEWTGLContext.destroyWindow(winctx);
-
+
long t3 = System.nanoTime();
-
- System.err.println("t1-t0: "+ (t1-t0)/1e6 +"ms");
- System.err.println("t3-t0: "+ (t3-t0)/1e6 +"ms");
- System.err.println("t3-t2: "+ (t3-t2)/1e6 +"ms");
+
+ System.err.println("t1-t0: "+ (t1-t0)/1e6 +"ms");
+ System.err.println("t3-t0: "+ (t3-t0)/1e6 +"ms");
+ System.err.println("t3-t2: "+ (t3-t2)/1e6 +"ms");
}
-
+
public static void main(String args[]) throws IOException {
System.err.println("main - start");
for(int i=0; i<args.length; i++) {
@@ -187,6 +182,6 @@ public class TestRulerNEWT01 extends UITestCase {
String tstname = TestRulerNEWT01.class.getName();
org.junit.runner.JUnitCore.main(tstname);
System.err.println("main - end");
- }
+ }
}