summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-07 08:46:18 +0200
committerSven Gothel <[email protected]>2023-04-07 08:46:18 +0200
commit84a6d63205ec49ddfb36b57fe2888425ecda3a5a (patch)
tree354cec2ac14a8932a01122c5234926e774ef874e /src/test
parent10b60e10ece3cbc3e0b8a68ac73229371530e0ba (diff)
PMVMatrix rewrite using Matrix4f, providing SyncMatrix4f* for GLUniformData; Utilize Vec3f, Recti, .. throughout API (Matrix4f, AABBox, .. Graph*)
Big Easter Cleanup - Net -214 lines of code, despite new classes. - GLUniformData buffer can be synced w/ underlying data via SyncAction/SyncBuffer, e.g. SyncMatrix4f + SyncMatrices4f - PMVMatrix rewrite using Matrix4f and providing SyncMatrix4f/Matrices4f to sync w/ GLUniformData - Additional SyncMatrix4f16 + SyncMatrices4f16 covering Matrix4f sync w/ GLUniformData w/o PMVMatrix - Utilize Vec3f, Recti, .. throughout API (Matrix4f, AABBox, .. Graph*) - Moved FloatUtil -> Matrix4f, kept a few basic matrix ops for ProjectFloat - Most, if not all, float[] and int[] should have been moved to proper classes - int[] -> Recti for viewport rectangle - Matrix4f and PMVMatrix is covered by math unit tests (as was FloatUtil before) -> save Passed all unit tests on AMD64 GNU/Linux
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java29
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java263
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java306
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java67
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fMatrixMulNOUI.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java)82
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject01NOUI.java329
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject02NOUI.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java)83
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java153
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java43
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java109
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java54
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java47
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java42
40 files changed, 727 insertions, 1039 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java
index 50ceebdc5..a6fbb3642 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java
@@ -50,6 +50,8 @@ import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.PMVMatrix;
@@ -146,12 +148,12 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
getRenderer().init(gl);
}
- public static void mapWin2ObjectCoords(final PMVMatrix pmv, final int[] view,
+ public static void mapWin2ObjectCoords(final PMVMatrix pmv, final Recti view,
final float zNear, final float zFar,
final float orthoX, final float orthoY, final float orthoDist,
- final float[] winZ, final float[] objPos) {
+ final float[] winZ, final Vec3f objPos) {
winZ[0] = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar);
- pmv.gluUnProject(orthoX, orthoY, winZ[0], view, 0, objPos, 0);
+ pmv.gluUnProject(orthoX, orthoY, winZ[0], view, objPos);
}
@Override
@@ -161,26 +163,21 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
System.err.printf("Reshape: zNear %f, zFar %f%n", zNear, zFar);
- System.err.printf("Reshape: Frustum: %s%n", pmv.glGetFrustum());
+ System.err.printf("Reshape: Frustum: %s%n", pmv.getFrustum());
{
final float orthoDist = 1f;
- final float[] obj00Coord = new float[3];
- final float[] obj11Coord = new float[3];
+ final Vec3f obj00Coord = new Vec3f();
+ final Vec3f obj11Coord = new Vec3f();
final float[] winZ = new float[1];
- final int[] view = new int[] { 0, 0, width, height };
+ final Recti view = new Recti(0, 0, width, height);
mapWin2ObjectCoords(pmv, view, zNear, zFar, 0f, 0f, orthoDist, winZ, obj00Coord);
- System.err.printf("Reshape: mapped.00: [%f, %f, %f], winZ %f -> [%f, %f, %f]%n", 0f, 0f, orthoDist, winZ[0], obj00Coord[0], obj00Coord[1], obj00Coord[2]);
+ System.err.printf("Reshape: mapped.00: [%f, %f, %f], winZ %f -> [%s]%n", 0f, 0f, orthoDist, winZ[0], obj00Coord);
mapWin2ObjectCoords(pmv, view, zNear, zFar, width, height, orthoDist, winZ, obj11Coord);
- System.err.printf("Reshape: mapped.11: [%f, %f, %f], winZ %f -> [%f, %f, %f]%n", (float)width, (float)height, orthoDist, winZ[0], obj11Coord[0], obj11Coord[1], obj11Coord[2]);
-
- nearPlane1Box.setSize( obj00Coord[0], // lx
- obj00Coord[1], // ly
- obj00Coord[2], // lz
- obj11Coord[0], // hx
- obj11Coord[1], // hy
- obj11Coord[2] );// hz
+ System.err.printf("Reshape: mapped.11: [%f, %f, %f], winZ %f -> [%s]%n", (float)width, (float)height, orthoDist, winZ[0], obj11Coord);
+
+ nearPlane1Box.setSize( obj00Coord, obj11Coord );
System.err.printf("Reshape: dist1Box: %s%n", nearPlane1Box);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java
index 9af3bd99b..b495fac5d 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java
@@ -392,7 +392,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
rs.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f);
if( bottomTextUseFrustum ) {
- regionBottom.setFrustum(pmv.glGetFrustum());
+ regionBottom.setFrustum(pmv.getFrustum());
}
if(!userInput) {
if( bottomTextUseFrustum ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
index 55a75d71e..e35f084db 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
@@ -119,7 +119,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
st.attachShaderProgram(gl, sp1, true);
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java
index 88e51db8b..efe903971 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java
@@ -259,7 +259,7 @@ public class ElektronenMultiplizierer implements GLEventListener {
st.uniform(gl, mScreenDimensionUniform);
pmvMatrix = new PMVMatrix();
- pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
index de2d3458a..57634b581 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
@@ -116,7 +116,7 @@ public class FBOMix2DemosES2 implements GLEventListener {
sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
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 88a3d7326..b466f460f 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
@@ -233,7 +233,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
pmvMatrix = new PMVMatrix();
st.attachObject("pmvMatrix", pmvMatrix);
- pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit
+ pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMvitMat()); // P, Mv, Mvi and Mvit
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
index 18c0ffd68..4ab944db9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
@@ -72,6 +72,7 @@ public class LandscapeES2 implements GLEventListener {
public void setVerbose(final boolean v) { verbose = v; }
+ @Override
public void init(final GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" LandscapeES2.init ...");
final GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -123,6 +124,7 @@ public class LandscapeES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" LandscapeES2.init FIN");
}
+ @Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
System.err.println(Thread.currentThread()+" LandscapeES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
@@ -139,6 +141,7 @@ public class LandscapeES2 implements GLEventListener {
shaderState.useProgram(gl, false);
}
+ @Override
public void dispose(final GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" LandscapeES2.dispose ... ");
final GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -149,6 +152,7 @@ public class LandscapeES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" LandscapeES2.dispose FIN");
}
+ @Override
public void display(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
// Shader fills complete framebuffer regardless of DEPTH, no Clear required.
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java
index 2169b93d0..d083b149c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java
@@ -53,6 +53,7 @@ public class LineSquareXDemoES2 implements GLEventListener {
public void setClearBuffers(final boolean v) { clearBuffers = v; }
+ @Override
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -76,7 +77,7 @@ public class LineSquareXDemoES2 implements GLEventListener {
sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -126,6 +127,7 @@ public class LineSquareXDemoES2 implements GLEventListener {
st.useProgram(gl, false);
}
+ @Override
public void dispose(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
immModeSink.destroy(gl);
@@ -133,6 +135,7 @@ public class LineSquareXDemoES2 implements GLEventListener {
st.destroy(gl);
}
+ @Override
public void display(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
if (multisample) {
@@ -154,6 +157,7 @@ public class LineSquareXDemoES2 implements GLEventListener {
}
// Unused routines
+ @Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
System.err.println("reshape ..");
final GL2ES2 gl = glad.getGL().getGL2ES2();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
index 3ec383ad8..954aeaf8e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
@@ -100,7 +100,7 @@ public class Mix2TexturesES2 implements GLEventListener {
sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
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 3808a4f84..aa89bcdc9 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
@@ -72,6 +72,7 @@ public class MultisampleDemoES2 implements GLEventListener {
public void setClearBuffers(final boolean v) { clearBuffers = v; }
+ @Override
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -95,7 +96,7 @@ public class MultisampleDemoES2 implements GLEventListener {
sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -126,6 +127,7 @@ public class MultisampleDemoES2 implements GLEventListener {
st.useProgram(gl, false);
}
+ @Override
public void dispose(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
immModeSink.destroy(gl);
@@ -133,6 +135,7 @@ public class MultisampleDemoES2 implements GLEventListener {
st.destroy(gl);
}
+ @Override
public void display(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
if (multisample) {
@@ -153,6 +156,7 @@ public class MultisampleDemoES2 implements GLEventListener {
}
// Unused routines
+ @Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
System.err.println("reshape ..");
final GL2ES2 gl = glad.getGL().getGL2ES2();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
index d59c1bb84..1d05d16a1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
@@ -67,10 +67,12 @@ public class PointsDemoES2 extends PointsDemo {
this.swapInterval = 1;
}
+ @Override
public void setSmoothPoints(final boolean v) {
pointParams.put(1, v ? 1.0f : 0.0f);
}
+ @Override
public void setPointParams(final float minSize, final float maxSize, final float distAttenConst, final float distAttenLinear, final float distAttenQuadratic, final float fadeThreshold) {
pointParams.put(2, minSize);
pointParams.put(3, maxSize);
@@ -80,6 +82,7 @@ public class PointsDemoES2 extends PointsDemo {
pointParams.put(4+3, fadeThreshold);
}
+ @Override
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -108,7 +111,7 @@ public class PointsDemoES2 extends PointsDemo {
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -143,6 +146,7 @@ public class PointsDemoES2 extends PointsDemo {
st.useProgram(gl, false);
}
+ @Override
public void display(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
gl.glClearColor(0f, 0f, 0f, 0f);
@@ -182,6 +186,7 @@ public class PointsDemoES2 extends PointsDemo {
st.useProgram(gl, false);
}
+ @Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
// Thread.dumpStack();
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -198,6 +203,7 @@ public class PointsDemoES2 extends PointsDemo {
st.useProgram(gl, false);
}
+ @Override
public void dispose(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
st.destroy(gl);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index eb96d1593..0dc9eb633 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -126,7 +126,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java
index 3b526401d..32f917f9f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java
@@ -123,7 +123,7 @@ public class RedSquareMappedES2 implements GLEventListener, TileRendererBase.Til
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
index e29981bb5..017b3e5fe 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
@@ -138,7 +138,7 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
st.ownUniform(pmvMatrixUniform);
if(!st.uniform(gl, pmvMatrixUniform)) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
index e360b5987..02782644a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
@@ -108,7 +108,7 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
index 540fb8eb3..4c2b5d57d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
@@ -227,7 +227,7 @@ public class TextureSequenceCubeES2 implements GLEventListener {
pmvMatrix = new PMVMatrix();
reshapePMV(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java
index 668d8877c..f0a92891a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java
@@ -35,6 +35,7 @@ import java.nio.FloatBuffer;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GL3;
+import com.jogamp.opengl.GL3ES3;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLException;
@@ -108,7 +109,7 @@ public class GeomShader01TextureGL3 implements GLEventListener {
final ShaderCode vs, gs, fs;
vs = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
- gs = ShaderCode.create(gl, GL3.GL_GEOMETRY_SHADER, this.getClass(),
+ gs = ShaderCode.create(gl, GL3ES3.GL_GEOMETRY_SHADER, this.getClass(),
"shader", "shader/bin", geomShaderBaseNames[geomShader], true);
fs = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
@@ -134,7 +135,7 @@ public class GeomShader01TextureGL3 implements GLEventListener {
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java
index 610ec7e98..65548e935 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java
@@ -33,6 +33,7 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GL2ES3;
import com.jogamp.opengl.GL2GL3;
+import com.jogamp.opengl.GL3ES3;
import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLEventListener;
@@ -81,7 +82,7 @@ public class TessellationShader01aGLSL440CoreHardcoded implements GLEventListene
gl.glGenVertexArrays(vertexArray.length, vertexArray, 0);
gl.glBindVertexArray(vertexArray[0]);
- gl.glPatchParameteri(GL4.GL_PATCH_VERTICES, 3);
+ gl.glPatchParameteri(GL3ES3.GL_PATCH_VERTICES, 3);
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE);
}
@@ -97,7 +98,7 @@ public class TessellationShader01aGLSL440CoreHardcoded implements GLEventListene
vertexOffset.put(0, (float)(Math.sin(value) * 0.5f));
vertexOffset.put(1, (float)(Math.cos(value) * 0.6f));
gl.glVertexAttrib4fv(0, vertexOffset);
- gl.glDrawArrays(GL4.GL_PATCHES, 0, 3);
+ gl.glDrawArrays(GL3ES3.GL_PATCHES, 0, 3);
}
@Override
@@ -170,12 +171,12 @@ public class TessellationShader01aGLSL440CoreHardcoded implements GLEventListene
if( null == vertexShader ) {
return null;
}
- final ShaderCode tessCtrlShader = createShader(gl, GL4.GL_TESS_CONTROL_SHADER, tessCtrlSource);
+ final ShaderCode tessCtrlShader = createShader(gl, GL3ES3.GL_TESS_CONTROL_SHADER, tessCtrlSource);
if( null == tessCtrlShader ) {
vertexShader.destroy(gl);
return null;
}
- final ShaderCode tessEvalShader = createShader(gl, GL4.GL_TESS_EVALUATION_SHADER, tessEvalSource);
+ final ShaderCode tessEvalShader = createShader(gl, GL3ES3.GL_TESS_EVALUATION_SHADER, tessEvalSource);
if( null == tessEvalShader ) {
vertexShader.destroy(gl);
tessCtrlShader.destroy(gl);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
index dcb76dd45..b5892ddca 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
@@ -33,6 +33,7 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GL2ES3;
import com.jogamp.opengl.GL2GL3;
+import com.jogamp.opengl.GL3ES3;
import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLEventListener;
@@ -82,7 +83,7 @@ public class TessellationShader01bGL4 implements GLEventListener {
gl.glGenVertexArrays(vertexArray.length, vertexArray, 0);
gl.glBindVertexArray(vertexArray[0]);
- gl.glPatchParameteri(GL4.GL_PATCH_VERTICES, 3);
+ gl.glPatchParameteri(GL3ES3.GL_PATCH_VERTICES, 3);
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE);
}
@@ -98,7 +99,7 @@ public class TessellationShader01bGL4 implements GLEventListener {
vertexOffset.put(0, (float)(Math.sin(value) * 0.5f));
vertexOffset.put(1, (float)(Math.cos(value) * 0.6f));
gl.glVertexAttrib4fv(0, vertexOffset);
- gl.glDrawArrays(GL4.GL_PATCHES, 0, 3);
+ gl.glDrawArrays(GL3ES3.GL_PATCHES, 0, 3);
}
@Override
@@ -126,9 +127,9 @@ public class TessellationShader01bGL4 implements GLEventListener {
final ShaderCode vs, tcs, tes, fs;
vs = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
- tcs = ShaderCode.create(gl, GL4.GL_TESS_CONTROL_SHADER, this.getClass(),
+ tcs = ShaderCode.create(gl, GL3ES3.GL_TESS_CONTROL_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
- tes = ShaderCode.create(gl, GL4.GL_TESS_EVALUATION_SHADER, this.getClass(),
+ tes = ShaderCode.create(gl, GL3ES3.GL_TESS_EVALUATION_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
fs = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java
index 841f2037c..c7f04531e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java
@@ -18,6 +18,7 @@ import com.jogamp.opengl.GLUniformData;
import com.jogamp.opengl.TraceGL4;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.GLArrayDataClient;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
@@ -102,7 +103,7 @@ public class TriangleInstancedRendererWithShaderState implements GLEventListener
initShader(gl);
projectionMatrix = new PMVMatrix();
- projectionMatrixUniform = new GLUniformData("mgl_PMatrix", 4, 4, projectionMatrix.glGetPMatrixf());
+ projectionMatrixUniform = new GLUniformData("mgl_PMatrix", 4, 4, projectionMatrix.getSyncPMat());
st.ownUniform(projectionMatrixUniform);
if(!st.uniform(gl, projectionMatrixUniform)) {
throw new GLException("Error setting mgl_PMatrix in shader: " + st);
@@ -170,7 +171,7 @@ public class TriangleInstancedRendererWithShaderState implements GLEventListener
projectionMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
projectionMatrix.glLoadIdentity();
projectionMatrix.gluPerspective(45, aspect, 0.001f, 20f);
- projectionMatrix.gluLookAt(0, 0, -10, 0, 0, 0, 0, 1, 0);
+ projectionMatrix.gluLookAt(new Vec3f(0, 0, -10), new Vec3f(0, 0, 0), new Vec3f(0, 1, 0));
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java
index a1f8ff5f6..fee3c7f4f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java
@@ -17,6 +17,7 @@ import com.jogamp.opengl.TraceGL4;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.PMVMatrix;
public class TrianglesInstancedRendererHardcoded implements GLEventListener {
@@ -99,7 +100,7 @@ public class TrianglesInstancedRendererHardcoded implements GLEventListener {
}
projectionMatrix.glScalef(winScale, winScale, winScale);
projectionMatrix.update();
- gl.glUniformMatrix4fv(projectionMatrixLocation, 1, false, projectionMatrix.glGetPMatrixf());
+ gl.glUniformMatrix4fv(projectionMatrixLocation, 1, false, projectionMatrix.getSyncPMat().getSyncFloats());
projectionMatrix.glPopMatrix();
generateTriangleTransform();
gl.glUniformMatrix4fv(transformMatrixLocation, NO_OF_INSTANCE, false, triangleTransform);
@@ -121,7 +122,7 @@ public class TrianglesInstancedRendererHardcoded implements GLEventListener {
projectionMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
projectionMatrix.glLoadIdentity();
projectionMatrix.gluPerspective(45, aspect, 0.001f, 20f);
- projectionMatrix.gluLookAt(0, 0, -10, 0, 0, 0, 0, 1, 0);
+ projectionMatrix.gluLookAt(new Vec3f(0, 0, -10), new Vec3f(0, 0, 0), new Vec3f(0, 1, 0));
}
@Override
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 321494afa..e40eb4b46 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
@@ -125,7 +125,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// setup mgl_PMVMatrix
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
pmvMatrixUniform.setLocation(gl, sp.program());
gl.glUniform(pmvMatrixUniform);
@@ -244,7 +244,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// setup mgl_PMVMatrix
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
st.ownUniform(pmvMatrixUniform);
@@ -336,7 +336,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// setup mgl_PMVMatrix
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -425,7 +425,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// setup mgl_PMVMatrix
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
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 2cf017f41..6f2265574 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
@@ -39,7 +39,6 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.io.IOException;
-import com.jogamp.nativewindow.NativeWindowFactory;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLCapabilities;
@@ -117,7 +116,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
// setup mgl_PMVMatrix
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -320,7 +319,7 @@ com.jogamp.opengl.GLException: Thread[main,5,main] glGetError() returned the fol
// setup mgl_PMVMatrix
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
st.ownUniform(pmvMatrixUniform);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
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 88146b2b8..5d571bc09 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
@@ -83,7 +83,7 @@ public class TestRulerNEWT01 extends UITestCase {
glWindow.addGLEventListener(new GLEventListener() {
final ShaderState st = new ShaderState();
final PMVMatrix pmvMatrix = new PMVMatrix();
- final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
final GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("gca_Vertices", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java
index 28e748d24..83ecf7380 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java
@@ -971,7 +971,7 @@ public class Matrix4fb {
* @param q the Quaternion representing the rotation
* @return this matrix for chaining
* @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54">Matrix-FAQ Q54</a>
- * @see Quaternion#toMatrix(float[], int)
+ * @see Quaternion#toMatrix(float[])
* @see #getRotation()
*/
public final Matrix4fb setToRotation(final Quaternion q) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java
deleted file mode 100644
index eaca73579..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/**
- * Copyright 2014 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.math;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.FixMethodOrder;
-import org.junit.runners.MethodSorters;
-
-import com.jogamp.common.os.Platform;
-import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
-
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtil03InversionNOUI extends JunitTracer {
-
- @Test
- public void test01Ident(){
- final float[] res1 = new float[16];
- final float[] res2 = new float[16];
- final float[] temp = new float[16];
-
- final float[] identity = new float[] { 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1 };
-
- FloatUtil.invertMatrix(identity, 0, res1, 0);
- System.err.println(FloatUtil.matrixToString(null, "inv-1: ", "%10.7f", res1, 0, 4, 4, false /* rowMajorOrder */));
- invertMatrix(identity, 0, res2, 0, temp);
- System.err.println(FloatUtil.matrixToString(null, "inv-2: ", "%10.7f", res2, 0, 4, 4, false /* rowMajorOrder */));
-
- Assert.assertArrayEquals("I1/I2 failure", res1, res2, FloatUtil.INV_DEVIANCE);
- Assert.assertArrayEquals("I2 failure", identity, res2, FloatUtil.INV_DEVIANCE);
- Assert.assertArrayEquals("I1 failure", identity, res1, FloatUtil.INV_DEVIANCE);
- }
-
- private void testImpl(final float[] matrix) {
- final float[] inv1_0 = new float[16];
- final float[] inv1_1 = new float[16];
- final float[] inv1_2 = new float[16];
- final float[] inv2_0 = new float[16];
- final float[] inv2_1 = new float[16];
- final float[] inv2_2 = new float[16];
- final float[] temp = new float[16];
-
- System.err.println(FloatUtil.matrixToString(null, "orig : ", "%10.7f", matrix, 0, 4, 4, false /* rowMajorOrder */));
- invertMatrix(matrix, 0, inv1_0, 0, temp);
- invertMatrix(inv1_0, 0, inv2_0, 0, temp);
- System.err.println(FloatUtil.matrixToString(null, "inv1_0: ", "%10.7f", inv1_0, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "inv2_0: ", "%10.7f", inv2_0, 0, 4, 4, false /* rowMajorOrder */));
- FloatUtil.invertMatrix(matrix, 0, inv1_1, 0);
- FloatUtil.invertMatrix(inv1_1, 0, inv2_1, 0);
- System.err.println(FloatUtil.matrixToString(null, "inv1_1: ", "%10.7f", inv1_1, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "inv2_1: ", "%10.7f", inv2_1, 0, 4, 4, false /* rowMajorOrder */));
- FloatUtil.invertMatrix(matrix, inv1_2);
- FloatUtil.invertMatrix(inv1_2, inv2_2);
- System.err.println(FloatUtil.matrixToString(null, "inv1_2: ", "%10.7f", inv1_2, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "inv2_2: ", "%10.7f", inv2_2, 0, 4, 4, false /* rowMajorOrder */));
-
- Assert.assertArrayEquals("I1_1/I1_2 failure", inv1_1, inv1_2, FloatUtil.INV_DEVIANCE);
- Assert.assertArrayEquals("I2_1/I2_2 failure", inv2_1, inv2_2, FloatUtil.INV_DEVIANCE);
-
- Assert.assertArrayEquals("I1_0/I1_1 failure", inv1_0, inv1_2, FloatUtil.INV_DEVIANCE);
- Assert.assertArrayEquals("I2_0/I2_1 failure", inv2_0, inv2_2, FloatUtil.INV_DEVIANCE);
-
- Assert.assertArrayEquals("I1 failure", matrix, inv2_0, FloatUtil.INV_DEVIANCE);
- Assert.assertArrayEquals("I2 failure", matrix, inv2_2, FloatUtil.INV_DEVIANCE);
- Assert.assertArrayEquals("I2 failure", matrix, inv2_1, FloatUtil.INV_DEVIANCE);
- }
-
- @Test
- public void test02(){
- final float[] p = new float[] { 2.3464675f, 0, 0, 0,
- 0, 2.4142134f, 0, 0,
- 0, 0, -1.0002f, -1,
- 0, 0, -20.002f, 0 };
- testImpl(p);
- }
-
- @Test
- public void test03(){
- final float[] mv = new float[] { 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, -200, 1 } ;
- testImpl(mv);
- }
-
- @Test
- public void test04(){
- final float[] p = new float[] { 2.3464675f, 0, 0, 0,
- 0, 2.4142134f, 0, 0,
- 0, 0, -1.0002f, -1,
- 0, 0, -20.002f, 0 };
-
- testImpl(p);
- }
-
- @Test
- public void test05Perf(){
- final float[] p1 = new float[] { 2.3464675f, 0, 0, 0,
- 0, 2.4142134f, 0, 0,
- 0, 0, -1.0002f, -1,
- 0, 0, -20.002f, 0 };
-
- final float[] p2 = new float[]{ 26, 59, 143, 71,
- 59, 174, 730, 386,
- 143, 730, 9770, 5370,
- 71, 386, 5370, 2954 };
-
- final float[] res1 = new float[16];
- final float[] res2 = new float[16];
- final float[] temp = new float[16];
-
- final int loops = 1000000;
- long tI0 = 0;
- long tI1 = 0;
- long tI2 = 0;
-
- // warm-up
- for(int i=0; i<10; i++) {
- invertMatrix(p1, 0, res2, 0, temp);
- FloatUtil.invertMatrix(p1, 0, res1, 0);
- FloatUtil.invertMatrix(p1, res1);
-
- invertMatrix(p2, 0, res2, 0, temp);
- FloatUtil.invertMatrix(p2, 0, res1, 0);
- FloatUtil.invertMatrix(p2, res1);
- }
-
-
- for(int i=0; i<loops; i++) {
-
- final long t_0 = Platform.currentTimeMillis();
-
- invertMatrix(p1, 0, res2, 0, temp);
- final long t_1 = Platform.currentTimeMillis();
- tI0 += t_1 - t_0;
-
- FloatUtil.invertMatrix(p1, 0, res1, 0);
- final long t_2 = Platform.currentTimeMillis();
- tI1 += t_2 - t_1;
-
- FloatUtil.invertMatrix(p1, res1);
- final long t_3 = Platform.currentTimeMillis();
- tI2 += t_3 - t_2;
-
- invertMatrix(p2, 0, res2, 0, temp);
- final long t_4 = Platform.currentTimeMillis();
- tI0 += t_4 - t_3;
-
- FloatUtil.invertMatrix(p2, 0, res1, 0);
- final long t_5 = Platform.currentTimeMillis();
- tI1 += t_5 - t_4;
-
- FloatUtil.invertMatrix(p2, res2);
- final long t_6 = Platform.currentTimeMillis();
- tI2 += t_6 - t_5;
- }
- System.err.printf("Summary loops %6d: I1 %6d ms total, %f ms/inv%n", loops, tI0, (double)tI0/loops);
- System.err.printf("Summary loops %6d: I2 %6d ms total, %f ms/inv%n", loops, tI1, (double)tI1/loops);
- System.err.printf("Summary loops %6d: I3 %6d ms total, %f ms/inv%n", loops, tI2, (double)tI2/loops);
-
- }
-
- public static float[] invertMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset, final float[/*4*4*/] temp) {
- int i, j, k, swap;
- float t;
- for (i = 0; i < 4; i++) {
- final int i4 = i*4;
- for (j = 0; j < 4; j++) {
- temp[i4+j] = msrc[i4+j+msrc_offset];
- }
- }
- FloatUtil.makeIdentity(mres, mres_offset);
-
- for (i = 0; i < 4; i++) {
- final int i4 = i*4;
-
- //
- // Look for largest element in column
- //
- swap = i;
- for (j = i + 1; j < 4; j++) {
- if (Math.abs(temp[j*4+i]) > Math.abs(temp[i4+i])) {
- swap = j;
- }
- }
-
- if (swap != i) {
- final int swap4 = swap*4;
- //
- // Swap rows.
- //
- for (k = 0; k < 4; k++) {
- t = temp[i4+k];
- temp[i4+k] = temp[swap4+k];
- temp[swap4+k] = t;
-
- t = mres[i4+k+mres_offset];
- mres[i4+k+mres_offset] = mres[swap4+k+mres_offset];
- mres[swap4+k+mres_offset] = t;
- }
- }
-
- if (temp[i4+i] == 0) {
- //
- // No non-zero pivot. The matrix is singular, which shouldn't
- // happen. This means the user gave us a bad matrix.
- //
- return null;
- }
-
- t = temp[i4+i];
- for (k = 0; k < 4; k++) {
- temp[i4+k] /= t;
- mres[i4+k+mres_offset] /= t;
- }
- for (j = 0; j < 4; j++) {
- if (j != i) {
- final int j4 = j*4;
- t = temp[j4+i];
- for (k = 0; k < 4; k++) {
- temp[j4+k] -= temp[i4+k] * t;
- mres[j4+k+mres_offset] -= mres[i4+k+mres_offset]*t;
- }
- }
- }
- }
- return mres;
- }
-
- public static void main(final String args[]) {
- org.junit.runner.JUnitCore.main(TestFloatUtil03InversionNOUI.class.getName());
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java
deleted file mode 100644
index 107190840..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/**
- * Copyright 2014-2023 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.math;
-
-import java.util.Arrays;
-
-import com.jogamp.common.nio.Buffers;
-import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
-import com.jogamp.opengl.glu.GLU;
-
-import jogamp.opengl.gl2.ProjectDouble;
-
-import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.util.PMVMatrix;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.FixMethodOrder;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtilProject01NOUI extends JunitTracer {
-
- static final float epsilon = 0.00001f;
-
- // Simple 10 x 10 view port
- static final int[] viewport = new int[] { 0,0,10,10};
-
- /**
- * PMVMatrix FloatUtil.mapObjToWinCoords() w/ separate P + Mv, against FloatUtil.mapObjToWinCoords() w/ PMV
- */
- @Test
- public void test01PMVMatrixToFloatUtil1() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
-
- final float[] winA00 = new float[4];
- final float[] winA01 = new float[4];
- final float[] winA10 = new float[4];
- final float[] winA11 = new float[4];
- final float[] winB00 = new float[4];
- final float[] winB01 = new float[4];
- final float[] winB10 = new float[4];
- final float[] winB11 = new float[4];
-
- final PMVMatrix m = new PMVMatrix();
- final float[] mat4PMv = new float[16];
- m.multPMvMatrixf(mat4PMv, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
-
- m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0);
- System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4PMv, viewport, winB00, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
-
- m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0);
- System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4PMv, viewport, winB01, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
-
- m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- m.glOrthof(0, 10, 0, 10, 1, -1);
- System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
- System.err.println(m);
- m.multPMvMatrixf(mat4PMv, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
-
- m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0);
- System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4PMv, viewport, winB10, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
-
- m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0);
- System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4PMv, viewport, winB11, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
-
- Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
- Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
- Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
- Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
- }
-
- /**
- * Actually both using same FloatUtil.mapObjToWinCoords() w/ separate P + Mv
- */
- @Test
- public void test01PMVMatrixToFloatUtil2() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
-
- final float[] winA00 = new float[4];
- final float[] winA01 = new float[4];
- final float[] winA10 = new float[4];
- final float[] winA11 = new float[4];
- final float[] winB00 = new float[4];
- final float[] winB01 = new float[4];
- final float[] winB10 = new float[4];
- final float[] winB11 = new float[4];
-
- final PMVMatrix m = new PMVMatrix();
- final float[] mat4Mv = new float[16];
- final float[] mat4P = new float[16];
-
- m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
- m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
-
- m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0);
- System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
-
- m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0);
- System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
-
- m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- m.glOrthof(0, 10, 0, 10, 1, -1);
- System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
- System.err.println(m);
- m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
- m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
-
- m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0);
- System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
-
- m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0);
- System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
-
- Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
- Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
- Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
- Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
- }
-
- /**
- * GLU ProjectFloat w/ same FloatUtil.mapObjToWinCoords() w/ separate P + Mv
- */
- @Test
- public void test03GLUToFloatUtil2() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
-
- final float[] winA00 = new float[4];
- final float[] winA01 = new float[4];
- final float[] winA10 = new float[4];
- final float[] winA11 = new float[4];
- final float[] winB00 = new float[4];
- final float[] winB01 = new float[4];
- final float[] winB10 = new float[4];
- final float[] winB11 = new float[4];
-
- final PMVMatrix m = new PMVMatrix();
- final float[] mat4Mv = new float[16];
- final float[] mat4P = new float[16];
- final GLU glu = new GLU();
-
- m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
- m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
-
- glu.gluProject(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA00, 0);
- System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
-
- glu.gluProject(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA01, 0);
- System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
-
- m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- m.glOrthof(0, 10, 0, 10, 1, -1);
- System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
- System.err.println(m);
- m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
- m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
-
- glu.gluProject(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA10, 0);
- System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
-
- glu.gluProject(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA11, 0);
- System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
-
- Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
- Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
- Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
- Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
- }
-
- /**
- * GLU ProjectDouble against FloatUtil.mapObjToWinCoords() w/ separate P + Mv
- */
- @Test
- public void test04GLUDoubleToFloatUtil2() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
-
- final double[] winA00 = new double[4];
- final double[] winA01 = new double[4];
- final double[] winA10 = new double[4];
- final double[] winA11 = new double[4];
- final float[] winB00 = new float[4];
- final float[] winB01 = new float[4];
- final float[] winB10 = new float[4];
- final float[] winB11 = new float[4];
-
- final PMVMatrix m = new PMVMatrix();
- final float[] mat4Mv = new float[16];
- final float[] mat4P = new float[16];
- final ProjectDouble glu = new ProjectDouble();
-
- m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
- m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
- double[] d_mat4Mv = Buffers.getDoubleArray(mat4Mv, 0, null, 0, -1);
- double[] d_mat4P = Buffers.getDoubleArray(mat4P, 0, null, 0, -1);
-
- glu.gluProject(1f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA00, 0);
- System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
-
- glu.gluProject(0f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA01, 0);
- System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
-
- m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- m.glOrthof(0, 10, 0, 10, 1, -1);
- System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
- System.err.println(m);
- m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
- m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
- System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
- d_mat4Mv = Buffers.getDoubleArray(mat4Mv, 0, null, 0, -1);
- d_mat4P = Buffers.getDoubleArray(mat4P, 0, null, 0, -1);
-
- glu.gluProject(1f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA10, 0);
- System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
-
- glu.gluProject(0f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA11, 0);
- System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
-
- double[] d_winBxx = Buffers.getDoubleArray(winB00, 0, null, 0, -1);
- Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", d_winBxx, winA00, epsilon);
- d_winBxx = Buffers.getDoubleArray(winB01, 0, null, 0, -1);
- Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", d_winBxx, winA01, epsilon);
- d_winBxx = Buffers.getDoubleArray(winB10, 0, null, 0, -1);
- Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", d_winBxx, winA10, epsilon);
- d_winBxx = Buffers.getDoubleArray(winB11, 0, null, 0, -1);
- Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", d_winBxx, winA11, epsilon);
- }
-
- public static void main(final String args[]) {
- org.junit.runner.JUnitCore.main(TestFloatUtilProject01NOUI.class.getName());
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java
index 510a437f3..b040caed9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java
@@ -206,73 +206,6 @@ public class TestMatrix4f02MulNOUI extends JunitTracer {
System.err.printf("Summary loops %6d: I5b %6d ms total, %f us/mul, I5b / I2 %f%%, I5b / I5a %f%%%n", loops, tI5b, tI5b*1e3/2.0/loops, (double)tI5b/(double)tI2*100.0, (double)tI5b/(double)tI5a*100.0);
}
- public static float[] invertMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset, final float[/*4*4*/] temp) {
- int i, j, k, swap;
- float t;
- for (i = 0; i < 4; i++) {
- final int i4 = i*4;
- for (j = 0; j < 4; j++) {
- temp[i4+j] = msrc[i4+j+msrc_offset];
- }
- }
- FloatUtil.makeIdentity(mres, mres_offset);
-
- for (i = 0; i < 4; i++) {
- final int i4 = i*4;
-
- //
- // Look for largest element in column
- //
- swap = i;
- for (j = i + 1; j < 4; j++) {
- if (Math.abs(temp[j*4+i]) > Math.abs(temp[i4+i])) {
- swap = j;
- }
- }
-
- if (swap != i) {
- final int swap4 = swap*4;
- //
- // Swap rows.
- //
- for (k = 0; k < 4; k++) {
- t = temp[i4+k];
- temp[i4+k] = temp[swap4+k];
- temp[swap4+k] = t;
-
- t = mres[i4+k+mres_offset];
- mres[i4+k+mres_offset] = mres[swap4+k+mres_offset];
- mres[swap4+k+mres_offset] = t;
- }
- }
-
- if (temp[i4+i] == 0) {
- //
- // No non-zero pivot. The matrix is singular, which shouldn't
- // happen. This means the user gave us a bad matrix.
- //
- return null;
- }
-
- t = temp[i4+i];
- for (k = 0; k < 4; k++) {
- temp[i4+k] /= t;
- mres[i4+k+mres_offset] /= t;
- }
- for (j = 0; j < 4; j++) {
- if (j != i) {
- final int j4 = j*4;
- t = temp[j4+i];
- for (k = 0; k < 4; k++) {
- temp[j4+k] -= temp[i4+k] * t;
- mres[j4+k+mres_offset] -= mres[i4+k+mres_offset]*t;
- }
- }
- }
- }
- return mres;
- }
-
public static void main(final String args[]) {
org.junit.runner.JUnitCore.main(TestMatrix4f02MulNOUI.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java
index f5b1a3151..268d4271d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java
@@ -52,9 +52,9 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
0, 0, 1, 0,
0, 0, 0, 1 };
- FloatUtil.invertMatrix(identity, 0, res1, 0);
+ FloatUtil.invertMatrix(identity, res1);
// System.err.println(FloatUtil.matrixToString(null, "inv-1: ", "%10.7f", res1, 0, 4, 4, false /* rowMajorOrder */));
- invertMatrix(identity, 0, res2, 0, temp);
+ invertMatrix(identity, res2, temp);
// System.err.println(FloatUtil.matrixToString(null, "inv-2: ", "%10.7f", res2, 0, 4, 4, false /* rowMajorOrder */));
Assert.assertArrayEquals("I1/I2 failure", res1, res2, FloatUtil.INV_DEVIANCE);
@@ -84,12 +84,12 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
final float[] temp = new float[16];
// System.err.println(FloatUtil.matrixToString(null, "orig : ", "%10.7f", matrix, 0, 4, 4, false /* rowMajorOrder */));
- invertMatrix(matrix, 0, inv1_0, 0, temp);
- invertMatrix(inv1_0, 0, inv2_0, 0, temp);
+ invertMatrix(matrix, inv1_0, temp);
+ invertMatrix(inv1_0, inv2_0, temp);
// System.err.println(FloatUtil.matrixToString(null, "inv1_0: ", "%10.7f", inv1_0, 0, 4, 4, false /* rowMajorOrder */));
// System.err.println(FloatUtil.matrixToString(null, "inv2_0: ", "%10.7f", inv2_0, 0, 4, 4, false /* rowMajorOrder */));
- FloatUtil.invertMatrix(matrix, 0, inv1_1, 0);
- FloatUtil.invertMatrix(inv1_1, 0, inv2_1, 0);
+ FloatUtil.invertMatrix(matrix, inv1_1);
+ FloatUtil.invertMatrix(inv1_1, inv2_1);
// System.err.println(FloatUtil.matrixToString(null, "inv1_1: ", "%10.7f", inv1_1, 0, 4, 4, false /* rowMajorOrder */));
// System.err.println(FloatUtil.matrixToString(null, "inv2_1: ", "%10.7f", inv2_1, 0, 4, 4, false /* rowMajorOrder */));
FloatUtil.invertMatrix(matrix, inv1_2);
@@ -227,7 +227,6 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
final int warmups = 1000;
final int loops = 10*1000*1000;
long tI0 = 0;
- long tI1 = 0;
long tI2 = 0;
long tI4a = 0;
long tI4b = 0;
@@ -236,35 +235,20 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
// warm-up
for(int i=0; i<warmups; i++) {
- invertMatrix(p1, 0, res, 0, temp);
+ invertMatrix(p1, res, temp);
}
long t_0 = Platform.currentTimeMillis();
for(int i=0; i<loops; i++) {
// I0: p1 -> res
- invertMatrix(p1, 0, res, 0, temp);
+ invertMatrix(p1, res, temp);
// I0: p2 -> res
- invertMatrix(p2, 0, res, 0, temp);
+ invertMatrix(p2, res, temp);
}
tI0 = Platform.currentTimeMillis() - t_0;
// warm-up
for(int i=0; i<warmups; i++) {
- FloatUtil.invertMatrix(p1, 0, res, 0);
- FloatUtil.invertMatrix(p2, 0, res, 0);
- }
- t_0 = Platform.currentTimeMillis();
- for(int i=0; i<loops; i++) {
- // I1: p1 -> res
- FloatUtil.invertMatrix(p1, 0, res, 0);
-
- // I1: p2 -> res
- FloatUtil.invertMatrix(p2, 0, res, 0);
- }
- tI1 = Platform.currentTimeMillis() - t_0;
-
- // warm-up
- for(int i=0; i<warmups; i++) {
FloatUtil.invertMatrix(p1, res);
FloatUtil.invertMatrix(p2, res);
}
@@ -367,24 +351,23 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
}
System.err.printf("Summary loops %6d: I0 %6d ms total, %f us/inv%n", loops, tI0, tI0*1e3/loops);
- System.err.printf("Summary loops %6d: I1 %6d ms total, %f us/inv, I1 / I0 %f%%%n", loops, tI1, tI1*1e3/2.0/loops, (double)tI1/(double)tI0*100.0);
- System.err.printf("Summary loops %6d: I2 %6d ms total, %f us/inv, I2 / I1 %f%%%n", loops, tI2, tI2*1e3/2.0/loops, (double)tI2/(double)tI1*100.0);
+ System.err.printf("Summary loops %6d: I2 %6d ms total, %f us/inv, I2 / I0 %f%%%n", loops, tI2, tI2*1e3/2.0/loops, tI2/(double)tI0*100.0);
System.err.printf("Summary loops %6d: I4a %6d ms total, %f us/inv, I4a / I2 %f%%%n", loops, tI4a, tI4a*1e3/2.0/loops, (double)tI4a/(double)tI2*100.0);
System.err.printf("Summary loops %6d: I4b %6d ms total, %f us/inv, I4b / I2 %f%%%n", loops, tI4b, tI4b*1e3/2.0/loops, (double)tI4b/(double)tI2*100.0);
System.err.printf("Summary loops %6d: I5a %6d ms total, %f us/inv, I5a / I2 %f%%%n", loops, tI5a, tI5a*1e3/2.0/loops, (double)tI5a/(double)tI2*100.0);
System.err.printf("Summary loops %6d: I5b %6d ms total, %f us/inv, I5b / I2 %f%%%n", loops, tI5b, tI5b*1e3/2.0/loops, (double)tI5b/(double)tI2*100.0);
}
- public static float[] invertMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset, final float[/*4*4*/] temp) {
+ public static float[] invertMatrix(final float[] msrc, final float[] mres, final float[/*4*4*/] temp) {
int i, j, k, swap;
float t;
for (i = 0; i < 4; i++) {
final int i4 = i*4;
for (j = 0; j < 4; j++) {
- temp[i4+j] = msrc[i4+j+msrc_offset];
+ temp[i4+j] = msrc[i4+j];
}
}
- FloatUtil.makeIdentity(mres, mres_offset);
+ FloatUtil.makeIdentity(mres);
for (i = 0; i < 4; i++) {
final int i4 = i*4;
@@ -409,9 +392,9 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
temp[i4+k] = temp[swap4+k];
temp[swap4+k] = t;
- t = mres[i4+k+mres_offset];
- mres[i4+k+mres_offset] = mres[swap4+k+mres_offset];
- mres[swap4+k+mres_offset] = t;
+ t = mres[i4+k];
+ mres[i4+k] = mres[swap4+k];
+ mres[swap4+k] = t;
}
}
@@ -426,7 +409,7 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
t = temp[i4+i];
for (k = 0; k < 4; k++) {
temp[i4+k] /= t;
- mres[i4+k+mres_offset] /= t;
+ mres[i4+k] /= t;
}
for (j = 0; j < 4; j++) {
if (j != i) {
@@ -434,7 +417,7 @@ public class TestMatrix4f03InversionNOUI extends JunitTracer {
t = temp[j4+i];
for (k = 0; k < 4; k++) {
temp[j4+k] -= temp[i4+k] * t;
- mres[j4+k+mres_offset] -= mres[i4+k+mres_offset]*t;
+ mres[j4+k] -= mres[i4+k]*t;
}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fMatrixMulNOUI.java
index 72b4453c6..67099cfab 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fMatrixMulNOUI.java
@@ -34,84 +34,84 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtil02MatrixMatrixMultNOUI extends JunitTracer {
+public class TestMatrix4fMatrixMulNOUI extends JunitTracer {
- final float[] m1 = new float[]{ 1, 3, 4, 0,
+ final Matrix4f m1 = new Matrix4f(new float[]{
+ 1, 3, 4, 0,
6, 7, 8, 5,
98, 7, 6, 9,
- 54, 3, 2, 5 };
+ 54, 3, 2, 5 });
- final float[] m2 = new float[]{ 1, 6, 98, 54,
+ final Matrix4f m2 = new Matrix4f(new float[]{
+ 1, 6, 98, 54,
3, 7, 7, 3,
4, 8, 6, 2,
- 0, 5, 9, 5 };
+ 0, 5, 9, 5 });
- final float[] m1xm2_RM = // m2xm1_CM
- new float[]{ 26, 59, 143, 71,
+ final Matrix4f m2xm1 =
+ new Matrix4f(new float[]{
+ 26, 59, 143, 71,
59, 174, 730, 386,
143, 730, 9770, 5370,
- 71, 386, 5370, 2954 };
+ 71, 386, 5370, 2954 });
- final float[] m2xm1_RM = // m1xm2_CM
- new float[]{12557, 893, 748, 1182,
+ final Matrix4f m1xm2 =
+ new Matrix4f(new float[]{
+ 12557, 893, 748, 1182,
893, 116, 116, 113,
748, 116, 120, 104,
- 1182, 113, 104, 131 };
+ 1182, 113, 104, 131 });
- public static final void multMatrixf_RM(final float[] a, final int a_off, final float[] b, final int b_off, final float[] d, final int d_off) {
+ public static final void multMatrixf_RM(final Matrix4f a, final Matrix4f b, final Matrix4f d) {
for (int i = 0; i < 4; i++) {
- final float ai0=a[a_off+i*4+0], ai1=a[a_off+i*4+1], ai2=a[a_off+i*4+2], ai3=a[a_off+i*4+3];
- d[d_off+i*4+0] = ai0 * b[b_off+0*4+0] + ai1 * b[b_off+1*4+0] + ai2 * b[b_off+2*4+0] + ai3 * b[b_off+3*4+0] ;
- d[d_off+i*4+1] = ai0 * b[b_off+0*4+1] + ai1 * b[b_off+1*4+1] + ai2 * b[b_off+2*4+1] + ai3 * b[b_off+3*4+1] ;
- d[d_off+i*4+2] = ai0 * b[b_off+0*4+2] + ai1 * b[b_off+1*4+2] + ai2 * b[b_off+2*4+2] + ai3 * b[b_off+3*4+2] ;
- d[d_off+i*4+3] = ai0 * b[b_off+0*4+3] + ai1 * b[b_off+1*4+3] + ai2 * b[b_off+2*4+3] + ai3 * b[b_off+3*4+3] ;
+ final float ai0=a.get(i*4+0), ai1=a.get(i*4+1), ai2=a.get(i*4+2), ai3=a.get(i*4+3);
+ d.set(i*4+0, ai0 * b.get(0*4+0) + ai1 * b.get(1*4+0) + ai2 * b.get(2*4+0) + ai3 * b.get(3*4+0) );
+ d.set(i*4+1, ai0 * b.get(0*4+1) + ai1 * b.get(1*4+1) + ai2 * b.get(2*4+1) + ai3 * b.get(3*4+1) );
+ d.set(i*4+2, ai0 * b.get(0*4+2) + ai1 * b.get(1*4+2) + ai2 * b.get(2*4+2) + ai3 * b.get(3*4+2) );
+ d.set(i*4+3, ai0 * b.get(0*4+3) + ai1 * b.get(1*4+3) + ai2 * b.get(2*4+3) + ai3 * b.get(3*4+3) );
}
}
@Test
public void testCM_m1xm2(){
-
- final float[] r = new float[16];
-
- FloatUtil.multMatrix(m1, 0, m2, 0, r, 0);
-
- Assert.assertArrayEquals(m2xm1_RM, r, 0f);
+ final Matrix4f r = new Matrix4f();
+ r.mul(m1, m2);
+ Assert.assertEquals(m1xm2, r);
}
@Test
public void testCM_m2xm1(){
-
- final float[] r = new float[16];
-
- FloatUtil.multMatrix(m2, 0, m1, 0, r, 0);
-
- Assert.assertArrayEquals(m1xm2_RM, r, 0f);
+ final Matrix4f r = new Matrix4f();
+ r.mul(m2, m1);
+ Assert.assertEquals(m2xm1, r);
}
@Test
public void testRM_m1xm2(){
+ final Matrix4f r1 = new Matrix4f();
+ final Matrix4f r2 = new Matrix4f();
+ multMatrixf_RM(m1, m2, r1);
+ Assert.assertEquals(m2xm1, r1);
- final float[] r = new float[16];
-
- multMatrixf_RM(m1, 0, m2, 0, r, 0);
-
- Assert.assertArrayEquals(m1xm2_RM, r, 0f);
+ r2.mul(m1, m2).transpose();
+ Assert.assertEquals(m2xm1, r1);
}
@Test
public void testRM_m2xm1(){
+ final Matrix4f r1 = new Matrix4f();
+ final Matrix4f r2 = new Matrix4f();
+ multMatrixf_RM(m2, m1, r1);
+ Assert.assertEquals(m1xm2, r1);
- final float[] r = new float[16];
-
- multMatrixf_RM(m2, 0, m1, 0, r, 0);
-
- Assert.assertArrayEquals(m2xm1_RM, r, 0f);
+ r2.mul(m2, m1).transpose();
+ Assert.assertEquals(m1xm2, r1);
}
public static void main(final String args[]) {
- org.junit.runner.JUnitCore.main(TestFloatUtil02MatrixMatrixMultNOUI.class.getName());
+ org.junit.runner.JUnitCore.main(TestMatrix4fMatrixMulNOUI.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject01NOUI.java
new file mode 100644
index 000000000..f32894818
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject01NOUI.java
@@ -0,0 +1,329 @@
+/**
+ * Copyright 2014-2023 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.math;
+
+import java.util.Arrays;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.junit.util.JunitTracer;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.glu.GLU;
+
+import jogamp.opengl.gl2.ProjectDouble;
+
+import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec3f;
+import com.jogamp.opengl.util.PMVMatrix;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMatrix4fProject01NOUI extends JunitTracer {
+
+ static final float epsilon = 0.00001f;
+
+ // Simple 10 x 10 view port
+ static final Recti viewport = new Recti(0,0,10,10);
+ static final int[] viewport_i4 = new int[] { 0, 0, 10, 10 };
+
+ /**
+ * PMVMatrix w/ separate P + Mv vs Matrix4f.mapObjToWin() w/ single PMv
+ *
+ * Both using same Matrix4f.mapObjToWin(..).
+ */
+ @Test
+ public void test01PMVMatrixToMatrix4f() {
+ final Vec3f winA00 = new Vec3f();
+ final Vec3f winA01 = new Vec3f();
+ final Vec3f winA10 = new Vec3f();
+ final Vec3f winA11 = new Vec3f();
+ final Vec3f winB00 = new Vec3f();
+ final Vec3f winB01 = new Vec3f();
+ final Vec3f winB10 = new Vec3f();
+ final Vec3f winB11 = new Vec3f();
+
+ final PMVMatrix m = new PMVMatrix();
+ final Matrix4f mat4PMv = new Matrix4f();
+ m.mulPMvMat(mat4PMv);
+ System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f"));
+
+ m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA00); // separate P + Mv
+ System.err.println("A.0.0 - Project 1,0 -->" + winA00);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB00); // single PMv
+ System.err.println("B.0.0 - Project 1,0 -->" + winB00);
+
+ m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA01);
+ System.err.println("A.0.1 - Project 0,0 -->" + winA01);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB01);
+ System.err.println("B.0.1 - Project 0,0 -->" + winB01);
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.mulPMvMat(mat4PMv);
+ System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f"));
+
+ m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA10);
+ System.err.println("A.1.0 - Project 1,0 -->" +winA10);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB10);
+ System.err.println("B.1.0 - Project 1,0 -->" +winB10);
+
+ m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA11);
+ System.err.println("A.1.1 - Project 0,0 -->" +winA11);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB11);
+ System.err.println("B.1.1 - Project 0,0 -->" +winB11);
+
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure", winB00, winA00);
+ Assert.assertEquals("A/B 0.1 Project 0,0 failure", winB01, winA01);
+ Assert.assertEquals("A/B 1.0 Project 1,0 failure", winB10, winA10);
+ Assert.assertEquals("A/B 1.1 Project 0,0 failure", winB11, winA11);
+ }
+
+ /**
+ * PMVMatrix vs Matrix4f.mapObjToWin(), both w/ separate P + Mv
+ *
+ * Both using same Matrix4f.mapObjToWin().
+ */
+ @Test
+ public void test01PMVMatrixToMatrix4f2() {
+ final Vec3f winA00 = new Vec3f();
+ final Vec3f winA01 = new Vec3f();
+ final Vec3f winA10 = new Vec3f();
+ final Vec3f winA11 = new Vec3f();
+ final Vec3f winB00 = new Vec3f();
+ final Vec3f winB01 = new Vec3f();
+ final Vec3f winB10 = new Vec3f();
+ final Vec3f winB11 = new Vec3f();
+
+ final PMVMatrix m = new PMVMatrix();
+ final Matrix4f mat4Mv = new Matrix4f();
+ final Matrix4f mat4P = new Matrix4f();
+ final float[] mat4Mv_f16 = new float[16];
+ final float[] mat4P_f16 = new float[16];
+
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv_f16, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */));
+ mat4Mv.load( m.getMat(GLMatrixFunc.GL_MODELVIEW_MATRIX) );
+ mat4P.load( m.getMat(GLMatrixFunc.GL_PROJECTION_MATRIX) );
+ Assert.assertEquals(new Matrix4f(mat4Mv_f16), mat4Mv);
+ Assert.assertEquals(new Matrix4f(mat4P_f16), mat4P);
+ Assert.assertEquals(mat4Mv, m.getMviMat());
+ Assert.assertEquals(mat4P, m.getPMat());
+
+ m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA00);
+ System.err.println("A.0.0 - Project 1,0 -->" + winA00);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB00);
+ System.err.println("B.0.0 - Project 1,0 -->" + winB00);
+
+ m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA01);
+ System.err.println("A.0.1 - Project 0,0 -->" + winA01);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB01);
+ System.err.println("B.0.1 - Project 0,0 -->" + winB01);
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv_f16, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */));
+ mat4Mv.load( m.getMat(GLMatrixFunc.GL_MODELVIEW_MATRIX) );
+ mat4P.load( m.getMat(GLMatrixFunc.GL_PROJECTION_MATRIX) );
+ Assert.assertEquals(new Matrix4f(mat4Mv_f16), mat4Mv);
+ Assert.assertEquals(new Matrix4f(mat4P_f16), mat4P);
+ Assert.assertEquals(mat4Mv, m.getMviMat());
+ Assert.assertEquals(mat4P, m.getPMat());
+
+ m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA10);
+ System.err.println("A.1.0 - Project 1,0 -->" +winA10);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB10);
+ System.err.println("B.1.0 - Project 1,0 -->" +winB10);
+
+ m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA11);
+ System.err.println("A.1.1 - Project 0,0 -->" +winA11);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB11);
+ System.err.println("B.1.1 - Project 0,0 -->" +winB11);
+
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure", winB00, winA00);
+ Assert.assertEquals("A/B 0.1 Project 0,0 failure", winB01, winA01);
+ Assert.assertEquals("A/B 1.0 Project 1,0 failure", winB10, winA10);
+ Assert.assertEquals("A/B 1.1 Project 0,0 failure", winB11, winA11);
+ }
+
+ /**
+ * GLU ProjectFloat vs Matrix4f.mapObjToWin(), both w/ separate P + Mv
+ */
+ @Test
+ public void test03GLUToMatrix4f2() {
+ final float[] winA00 = new float[4];
+ final float[] winA01 = new float[4];
+ final float[] winA10 = new float[4];
+ final float[] winA11 = new float[4];
+ final Vec3f winB00 = new Vec3f();
+ final Vec3f winB01 = new Vec3f();
+ final Vec3f winB10 = new Vec3f();
+ final Vec3f winB11 = new Vec3f();
+
+ final PMVMatrix m = new PMVMatrix();
+ final Matrix4f mat4Mv = new Matrix4f();
+ final Matrix4f mat4P = new Matrix4f();
+ final float[] mat4Mv_f16 = new float[16];
+ final float[] mat4P_f16 = new float[16];
+ final GLU glu = new GLU();
+
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv_f16, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */));
+ mat4Mv.load( m.getMvMat() );
+ mat4P.load( m.getPMat() );
+
+ glu.gluProject(1f, 0f, 0f, mat4Mv_f16, 0, mat4P_f16, 0, viewport_i4, 0, winA00, 0);
+ System.err.println("A.0.0 - Project 1,0 -->" + winA00);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB00);
+ System.err.println("B.0.0 - Project 1,0 -->" + winB00);
+
+ glu.gluProject(0f, 0f, 0f, mat4Mv_f16, 0, mat4P_f16, 0, viewport_i4, 0, winA01, 0);
+ System.err.println("A.0.1 - Project 0,0 -->" + winA01);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB01);
+ System.err.println("B.0.1 - Project 0,0 -->" + winB01);
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv_f16, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */));
+ mat4Mv.load( m.getMvMat() );
+ mat4P.load( m.getPMat() );
+
+ glu.gluProject(1f, 0f, 0f, mat4Mv_f16, 0, mat4P_f16, 0, viewport_i4, 0, winA10, 0);
+ System.err.println("A.1.0 - Project 1,0 -->" +winA10);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB10);
+ System.err.println("B.1.0 - Project 1,0 -->" +winB10);
+
+ glu.gluProject(0f, 0f, 0f, mat4Mv_f16, 0, mat4P_f16, 0, viewport_i4, 0, winA11, 0);
+ System.err.println("A.1.1 - Project 0,0 -->" +winA11);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB11);
+ System.err.println("B.1.1 - Project 0,0 -->" +winB11);
+
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure", winB00, new Vec3f(winA00));
+ Assert.assertEquals("A/B 0.1 Project 0,0 failure", winB01, new Vec3f(winA01));
+ Assert.assertEquals("A/B 1.0 Project 1,0 failure", winB10, new Vec3f(winA10));
+ Assert.assertEquals("A/B 1.1 Project 0,0 failure", winB11, new Vec3f(winA11));
+ }
+
+ /**
+ * GLU ProjectDouble vs Matrix4f.mapObjToWin(), both w/ separate P + Mv
+ */
+ @Test
+ public void test04GLUDoubleToMatrix4f2() {
+ final double[] winA00 = new double[3];
+ final double[] winA01 = new double[3];
+ final double[] winA10 = new double[3];
+ final double[] winA11 = new double[3];
+ final Vec3f winB00 = new Vec3f();
+ final Vec3f winB01 = new Vec3f();
+ final Vec3f winB10 = new Vec3f();
+ final Vec3f winB11 = new Vec3f();
+
+ final PMVMatrix m = new PMVMatrix();
+ final Matrix4f mat4Mv = new Matrix4f();
+ final Matrix4f mat4P = new Matrix4f();
+ final float[] mat4Mv_f16 = new float[16];
+ final float[] mat4P_f16 = new float[16];
+ final ProjectDouble glu = new ProjectDouble();
+
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv_f16, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */));
+ mat4Mv.load( m.getMvMat() );
+ mat4P.load( m.getPMat() );
+ double[] mat4Mv_d16 = Buffers.getDoubleArray(mat4Mv_f16, 0, null, 0, -1);
+ double[] mat4P_d16 = Buffers.getDoubleArray(mat4P_f16, 0, null, 0, -1);
+
+ glu.gluProject(1f, 0f, 0f, mat4Mv_d16, 0, mat4P_d16, 0, viewport_i4, 0, winA00, 0);
+ System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB00);
+ System.err.println("B.0.0 - Project 1,0 -->" + winB00);
+
+ glu.gluProject(0f, 0f, 0f, mat4Mv_d16, 0, mat4P_d16, 0, viewport_i4, 0, winA01, 0);
+ System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB01);
+ System.err.println("B.0.1 - Project 0,0 -->" + winB01);
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv_f16, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */));
+ mat4Mv.load( m.getMvMat() );
+ mat4P.load( m.getPMat() );
+ mat4Mv_d16 = Buffers.getDoubleArray(mat4Mv_f16, 0, null, 0, -1);
+ mat4P_d16 = Buffers.getDoubleArray(mat4P_f16, 0, null, 0, -1);
+
+ glu.gluProject(1f, 0f, 0f, mat4Mv_d16, 0, mat4P_d16, 0, viewport_i4, 0, winA10, 0);
+ System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB10);
+ System.err.println("B.1.0 - Project 1,0 -->" +winB10);
+
+ glu.gluProject(0f, 0f, 0f, mat4Mv_d16, 0, mat4P_d16, 0, viewport_i4, 0, winA11, 0);
+ System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB11);
+ System.err.println("B.1.1 - Project 0,0 -->" +winB11);
+
+ final float[] tmp = new float[3];
+ double[] d_winBxx = Buffers.getDoubleArray(winB00.get(tmp), 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", d_winBxx, winA00, epsilon);
+ d_winBxx = Buffers.getDoubleArray(winB01.get(tmp), 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", d_winBxx, winA01, epsilon);
+ d_winBxx = Buffers.getDoubleArray(winB10.get(tmp), 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", d_winBxx, winA10, epsilon);
+ d_winBxx = Buffers.getDoubleArray(winB11.get(tmp), 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", d_winBxx, winA11, epsilon);
+ }
+
+ public static void main(final String args[]) {
+ org.junit.runner.JUnitCore.main(TestMatrix4fProject01NOUI.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject02NOUI.java
index c715a41a0..329c122ac 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject02NOUI.java
@@ -32,6 +32,10 @@ import java.util.Arrays;
import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec2f;
+import com.jogamp.opengl.math.Vec3f;
import org.junit.Assert;
import org.junit.Test;
@@ -39,87 +43,78 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtilProject02NOUI extends JunitTracer {
+public class TestMatrix4fProject02NOUI extends JunitTracer {
static final float epsilon = 0.00001f;
@Test
- public void test01FloatUtilProject() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
+ public void test01() {
+ final Vec3f winHas = new Vec3f();
+ final Vec2f winExp = new Vec2f( 297, 360 );
- final float[] winHas = new float[3];
- final int[] winExp = { 297, 360 };
+ final Recti viewport = new Recti(0, 0, 1280, 720);
- final int[] viewport = new int[] { 0, 0, 1280, 720 };
-
-
- final float[] mat4Mv = new float[] {
+ final Matrix4f mat4Mv = new Matrix4f(new float[] {
0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
- -0.09278385341167450000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f
- };
- final float[] mat4P = new float[] {
+ -0.09278385341167450000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f });
+
+ final Matrix4f mat4P = new Matrix4f(new float[] {
1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
- 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f,
- };
+ 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f });
- final float[] objPos = { 0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f };
+ final Vec3f objPos = new Vec3f(0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f);
System.err.println("pMv");
- System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4Mv, 0, 4, 4, true /* rowMajorOrder */));
+ System.err.println(mat4Mv.toString(null, "", "%25.20ff"));
System.err.println("pP");
- System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4P, 0, 4, 4, true/* rowMajorOrder */));
+ System.err.println(mat4P.toString(null, "", "%25.20ff"));
- FloatUtil.mapObjToWin(objPos[0], objPos[1], objPos[2], mat4Mv, 0, mat4P, 0, viewport, 0, winHas, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winHas));
+ Matrix4f.mapObjToWin(objPos, mat4Mv, mat4P, viewport, winHas);
+ System.err.println("B.0.0 - Project 1,0 -->" + winHas);
- Assert.assertEquals("A/B 0.0 Project 1,0 failure.x", winExp[0], Math.round(winHas[0]));
- Assert.assertEquals("A/B 0.0 Project 1,0 failure.y", winExp[1], Math.round(winHas[1]));
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.x", winExp.x(), Math.round(winHas.x()), epsilon);
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.y", winExp.y(), Math.round(winHas.y()), epsilon);
}
@Test
- public void test02GLUFloatUtil() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
+ public void test02() {
+ final Vec3f winHas = new Vec3f();
+ final Vec2f winExp = new Vec2f( 136, 360 );
- final float[] winHas = new float[3];
- final int[] winExp = { 136, 360 };
+ final Recti viewport = new Recti(0, 0, 1280, 720);
- final int[] viewport = new int[] { 0, 0, 1280, 720 };
-
-
- final float[] mat4Mv = new float[] {
+ // m30 (row 3, column 0) differs from test01
+ final Matrix4f mat4Mv = new Matrix4f(new float[] {
0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
- -0.13065303862094880000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f,
- };
- final float[] mat4P = new float[] {
+ -0.13065303862094880000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f });
+
+ final Matrix4f mat4P = new Matrix4f(new float[] {
1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
- 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f,
- };
+ 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f });
- final float[] objPos = { 0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f };
+ final Vec3f objPos = new Vec3f(0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f);
System.err.println("pMv");
- System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4Mv, 0, 4, 4, true /* rowMajorOrder */));
+ System.err.println(mat4Mv.toString(null, "", "%25.20ff"));
System.err.println("pP");
- System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4P, 0, 4, 4, true/* rowMajorOrder */));
+ System.err.println(mat4P.toString(null, "", "%25.20ff"));
- FloatUtil.mapObjToWin(objPos[0], objPos[1], objPos[2], mat4Mv, 0, mat4P, 0, viewport, 0, winHas, 0, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winHas));
+ Matrix4f.mapObjToWin(objPos, mat4Mv, mat4P, viewport, winHas);
+ System.err.println("B.0.0 - Project 1,0 -->" + winHas);
- Assert.assertEquals("A/B 0.0 Project 1,0 failure.x", winExp[0], Math.round(winHas[0]));
- Assert.assertEquals("A/B 0.0 Project 1,0 failure.y", winExp[1], Math.round(winHas[1]));
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.x", winExp.x(), Math.round(winHas.x()), epsilon);
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.y", winExp.y(), Math.round(winHas.y()), epsilon);
}
public static void main(final String args[]) {
- org.junit.runner.JUnitCore.main(TestFloatUtilProject02NOUI.class.getName());
+ org.junit.runner.JUnitCore.main(TestMatrix4fProject02NOUI.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java
index 04413315a..d2abbb4c8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java
@@ -48,6 +48,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
import com.jogamp.opengl.math.geom.Frustum;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -77,46 +78,39 @@ public class TestPMVMatrix01NEWT extends UITestCase {
2.0f, 4.0f, 6.0f } );
// Translated xyz 123 - Row - In row major order !
- static FloatBuffer translated123R = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 1.0f, 0.0f, 2.0f,
- 0.0f, 0.0f, 1.0f, 3.0f,
- 0.0f, 0.0f, 0.0f, 1.0f } );
+ static Matrix4f translated123R = new Matrix4f( new float[] { 1.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 1.0f, 0.0f, 2.0f,
+ 0.0f, 0.0f, 1.0f, 3.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f } );
// Translated xyz 123 - Column - In column major order !
- static FloatBuffer translated123C = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 1.0f, 2.0f, 3.0f, 1.0f } );
+ static Matrix4f translated123C = new Matrix4f( new float[] { 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 1.0f, 2.0f, 3.0f, 1.0f } );
// Translated xyz 123 - Inverse - In column major order !
- static FloatBuffer translated123I = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- -1.0f, -2.0f, -3.0f, 1.0f } );
+ static Matrix4f translated123I = new Matrix4f( new float[] { 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ -1.0f, -2.0f, -3.0f, 1.0f } );
// Translated xyz 123 - Inverse and Transposed - In column major order !
- static FloatBuffer translated123IT = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, -1.0f,
- 0.0f, 1.0f, 0.0f, -2.0f,
- 0.0f, 0.0f, 1.0f, -3.0f,
- 0.0f, 0.0f, 0.0f, 1.0f } );
+ static Matrix4f translated123IT = new Matrix4f( new float[] { 1.0f, 0.0f, 0.0f, -1.0f,
+ 0.0f, 1.0f, 0.0f, -2.0f,
+ 0.0f, 0.0f, 1.0f, -3.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f } );
@Test
- @SuppressWarnings("deprecation")
public void test00MatrixToString() {
- final String s4x4Cpmv = PMVMatrix.matrixToString(null, "%10.5f", translated123C).toString();
- final String s4x4Cflu = FloatUtil.matrixToString(null, null, "%10.5f", translated123C, 0, 4, 4, false).toString();
- final String s4x4Rflu = FloatUtil.matrixToString(null, null, "%10.5f", translated123R, 0, 4, 4, true).toString();
- System.err.println("PMV-C-O 4x4: ");
- System.err.println(s4x4Cpmv);
- System.err.println();
+ final String s4x4Cflu = translated123C.toString(null, null, "%10.5f").toString();
+ final String s4x4Rflu = translated123R.toString(null, null, "%10.5f").toString();
System.err.println("FLU-C-O 4x4: ");
System.err.println(s4x4Cflu);
System.err.println();
System.err.println("FLU-R-O 4x4: ");
System.err.println(s4x4Rflu);
System.err.println();
- Assert.assertEquals(s4x4Cpmv, s4x4Cflu);
- Assert.assertEquals(s4x4Cflu, s4x4Rflu);
final String s2x3Rflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix2x3R, 0, 2, 3, true).toString();
final String s2x3Cflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix2x3C, 0, 2, 3, false).toString();
@@ -145,10 +139,9 @@ public class TestPMVMatrix01NEWT extends UITestCase {
* The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated.
* </p>
*/
- @SuppressWarnings("deprecation")
@Test
public void test01MviUpdateTraditionalAccess() {
- FloatBuffer p, mv, mvi, mvit;
+ Matrix4f p, mv, mvi, mvit;
Frustum frustum;
boolean b;
final PMVMatrix pmv = new PMVMatrix();
@@ -161,11 +154,11 @@ public class TestPMVMatrix01NEWT extends UITestCase {
//
// Action #0
//
- final FloatBuffer ident;
+ final Matrix4f ident;
{
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
- ident = pmv.glGetPMatrixf();
+ ident = pmv.getPMat();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
@@ -195,23 +188,23 @@ public class TestPMVMatrix01NEWT extends UITestCase {
//
// Get
//
- p = pmv.glGetPMatrixf();
- MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon);
- mv = pmv.glGetMvMatrixf();
- MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon);
- mvi = pmv.glGetMviMatrixf();
- MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon);
+ p = pmv.getPMat();
+ MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon);
+ mv = pmv.getMvMat();
+ MiscUtils.assertMatrix4fEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon);
+ mvi = pmv.getMviMat();
+ MiscUtils.assertMatrix4fEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon);
Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask());
Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits());
- frustum = pmv.glGetFrustum();
+ frustum = pmv.getFrustum();
Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value!
Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask());
// System.err.println("P3: "+pmv.toString());
- mvit = pmv.glGetMvitMatrixf();
- MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
+ mvit = pmv.getMvitMat();
+ MiscUtils.assertMatrix4fEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask());
// System.err.println("P4: "+pmv.toString());
@@ -224,20 +217,20 @@ public class TestPMVMatrix01NEWT extends UITestCase {
Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits());
Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask());
- MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon);
- MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon);
- MiscUtils.assertFloatBufferNotEqual("Mvi already identity w/o update, "+pmv.toString(), ident, mvi, epsilon);
- MiscUtils.assertFloatBufferNotEqual("Mvit already identity w/o update, "+pmv.toString(), ident, mvit, epsilon);
- MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon);
- MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
+ MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon);
+ MiscUtils.assertMatrix4fNotEqual("Mvi already identity w/o update, "+pmv.toString(), ident, mvi, epsilon);
+ MiscUtils.assertMatrix4fNotEqual("Mvit already identity w/o update, "+pmv.toString(), ident, mvit, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value!
b = pmv.update(); // will clean dirty bits, since request has been made -> true
Assert.assertEquals("Update has not been perfomed, but requested", true, b);
Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask());
- MiscUtils.assertFloatBufferEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon);
- MiscUtils.assertFloatBufferEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon);
Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value!
}
@@ -247,10 +240,9 @@ public class TestPMVMatrix01NEWT extends UITestCase {
* The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated.
* </p>
*/
- @SuppressWarnings("deprecation")
@Test
public void test02MviUpdateShaderAccess() {
- final FloatBuffer p, mv, mvi, mvit;
+ final Matrix4f p, mv, mvi, mvit;
Frustum frustum;
boolean b;
final PMVMatrix pmv = new PMVMatrix();
@@ -263,11 +255,11 @@ public class TestPMVMatrix01NEWT extends UITestCase {
//
// Action #0
//
- final FloatBuffer ident;
+ final Matrix4f ident;
{
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
- ident = pmv.glGetPMatrixf();
+ ident = pmv.getPMat();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
@@ -282,24 +274,24 @@ public class TestPMVMatrix01NEWT extends UITestCase {
//
// Get
//
- p = pmv.glGetPMatrixf();
- MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon);
- mv = pmv.glGetMvMatrixf();
- MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon);
+ p = pmv.getPMat();
+ MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon);
+ mv = pmv.getMvMat();
+ MiscUtils.assertMatrix4fEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon);
Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits());
Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask());
- mvi = pmv.glGetMviMatrixf();
- MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon);
+ mvi = pmv.getMviMat();
+ MiscUtils.assertMatrix4fEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon);
Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits());
Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask());
- mvit = pmv.glGetMvitMatrixf();
- MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon);
+ mvit = pmv.getMvitMat();
+ MiscUtils.assertMatrix4fEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon);
Assert.assertEquals("Remaining dirty bits not Frustum, "+pmv.toString(), PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask());
- frustum = pmv.glGetFrustum();
+ frustum = pmv.getFrustum();
Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value!
Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask());
@@ -311,27 +303,27 @@ public class TestPMVMatrix01NEWT extends UITestCase {
Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test
Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits());
Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits());
- MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon);
- MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123C, mv, epsilon);
- MiscUtils.assertFloatBufferNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon);
- MiscUtils.assertFloatBufferNotEqual("Mvit already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
- MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon);
- MiscUtils.assertFloatBufferEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon);
+ MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123C, mv, epsilon);
+ MiscUtils.assertMatrix4fNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon);
+ MiscUtils.assertMatrix4fNotEqual("Mvit already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon);
Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value!
b = pmv.update(); // will clean dirty bits, since all requests has been made -> true
Assert.assertEquals("Update has not been perfomed, but requested", true, b);
Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits());
Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask());
- MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon);
- MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon);
+ MiscUtils.assertMatrix4fEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon);
// System.err.println("P2: "+pmv.toString());
}
@Test
public void test03MvTranslate() {
- final FloatBuffer pmvMv;
- // final FloatBuffer pmvMvi, pmvMvit;
+ final Matrix4f pmvMv;
+ // final Matrix4f pmvMvi, pmvMvit;
{
final PMVMatrix pmv = new PMVMatrix();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
@@ -340,7 +332,7 @@ public class TestPMVMatrix01NEWT extends UITestCase {
pmv.glLoadIdentity();
pmv.glTranslatef(5f, 6f, 7f);
- pmvMv = pmv.glGetMvMatrixf();
+ pmvMv = pmv.getMvMat();
// pmvMvi = pmv.glGetMviMatrixf();
// pmvMvit = pmv.glGetMvitMatrixf();
}
@@ -356,11 +348,13 @@ public class TestPMVMatrix01NEWT extends UITestCase {
gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv);
}
+ final Matrix4f glMvMat = new Matrix4f(glMv);
+
// System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString());
- MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+PlatformPropsImpl.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+
- ", actual"+PlatformPropsImpl.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(),
- glMv, pmvMv, epsilon);
+ MiscUtils.assertMatrix4fEquals("Arrays not equal, expected"+PlatformPropsImpl.NEWLINE+glMvMat+
+ ", actual"+PlatformPropsImpl.NEWLINE+pmvMv,
+ glMvMat, pmvMv, epsilon);
// System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi));
// System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit));
@@ -368,8 +362,8 @@ public class TestPMVMatrix01NEWT extends UITestCase {
@Test
public void test04MvTranslateRotate() {
- final FloatBuffer pmvMv;
- // final FloatBuffer pmvMvi, pmvMvit;
+ final Matrix4f pmvMv;
+ // final Matrix4f pmvMvi, pmvMvit;
{
final PMVMatrix pmv = new PMVMatrix();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
@@ -379,7 +373,7 @@ public class TestPMVMatrix01NEWT extends UITestCase {
pmv.glTranslatef(5f, 6f, 7f);
pmv.glRotatef(90f, 1f, 0f, 0f);
- pmvMv = pmv.glGetMvMatrixf();
+ pmvMv = pmv.getMvMat();
// pmvMvi = pmv.glGetMviMatrixf();
// pmvMvit = pmv.glGetMvitMatrixf();
}
@@ -396,11 +390,12 @@ public class TestPMVMatrix01NEWT extends UITestCase {
gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv);
}
+ final Matrix4f glMvMat = new Matrix4f(glMv);
// System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString());
- MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+PlatformPropsImpl.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+
- ", actual"+PlatformPropsImpl.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(),
- glMv, pmvMv, epsilon);
+ MiscUtils.assertMatrix4fEquals("Arrays not equal, expected"+PlatformPropsImpl.NEWLINE+glMvMat+
+ ", actual"+PlatformPropsImpl.NEWLINE+pmvMv,
+ glMvMat, pmvMv, epsilon);
// System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi));
// System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java
index d6a0beac6..391973215 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java
@@ -36,9 +36,10 @@ import org.junit.runners.MethodSorters;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
-import java.nio.FloatBuffer;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Vec3f;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
/**
* @author Thomas De Bodt
@@ -58,25 +59,22 @@ public class TestPMVMatrix02NOUI extends JunitTracer {
fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
// Look towards -z
fMat.gluLookAt(
- 0, 0, 0,
- 0, 0, -1,
- 0, 1, 0
+ new Vec3f(0, 0, 0),
+ new Vec3f(0, 0, -1),
+ new Vec3f(0, 1, 0)
);
- final FloatBuffer mvMatrix = fMat.glGetMvMatrixf();
- final float[] mvMatrixArr = new float[16];
- mvMatrix.asReadOnlyBuffer().get(mvMatrixArr);
- assertArrayEquals(
+ final Matrix4f mvMatrix = fMat.getMvMat();
+ assertEquals(
/**
* The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward.
*/
- new float[] {
+ new Matrix4f( new float[] {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
- },
- mvMatrixArr,
- 1e-6f
+ }),
+ mvMatrix
);
}
@Test
@@ -84,25 +82,22 @@ public class TestPMVMatrix02NOUI extends JunitTracer {
fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
// Look towards +y
fMat.gluLookAt(
- 0, 0, 0,
- 0, 1, 0,
- 0, 0, 1
+ new Vec3f(0, 0, 0),
+ new Vec3f(0, 1, 0),
+ new Vec3f(0, 0, 1)
);
- final FloatBuffer mvMatrix = fMat.glGetMvMatrixf();
- final float[] mvMatrixArr = new float[16];
- mvMatrix.asReadOnlyBuffer().get(mvMatrixArr);
- assertArrayEquals(
+ final Matrix4f mvMatrix = fMat.getMvMat();
+ assertEquals(
/**
* The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward.
*/
- new float[] {
+ new Matrix4f(new float[] {
1, 0, 0, 0,
0, 0, -1, 0,
0, 1, 0, 0,
0, 0, 0, 1
- },
- mvMatrixArr,
- 1e-6f
+ }),
+ mvMatrix
);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java
index 9468afbd2..e6697d356 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java
@@ -8,6 +8,9 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import jogamp.opengl.ProjectFloat;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.PMVMatrix;
import org.junit.Assert;
@@ -21,58 +24,56 @@ public class TestPMVMatrix03NOUI extends JunitTracer {
static final float epsilon = 0.00001f;
// Simple 10 x 10 view port
- static final int[] viewport = new int[] { 0,0,10,10};
+ static final Recti viewport = new Recti( 0,0,10,10 );
+ static final int[] viewport_i4 = new int[] { 0, 0, 10, 10 };
@Test
public void test01() {
- final float[] vec4Tmp1 = new float[4];
- final float[] vec4Tmp2 = new float[4];
-
- final float[] winA00 = new float[4];
- final float[] winA01 = new float[4];
- final float[] winA10 = new float[4];
- final float[] winA11 = new float[4];
- final float[] winB00 = new float[4];
- final float[] winB01 = new float[4];
- final float[] winB10 = new float[4];
- final float[] winB11 = new float[4];
+ final Vec3f winA00 = new Vec3f();
+ final Vec3f winA01 = new Vec3f();
+ final Vec3f winA10 = new Vec3f();
+ final Vec3f winA11 = new Vec3f();
+ final Vec3f winB00 = new Vec3f();
+ final Vec3f winB01 = new Vec3f();
+ final Vec3f winB10 = new Vec3f();
+ final Vec3f winB11 = new Vec3f();
final PMVMatrix m = new PMVMatrix();
- final float[] mat4PMv = new float[16];
- m.multPMvMatrixf(mat4PMv, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
+ final Matrix4f mat4PMv = new Matrix4f();
+ m.mulPMvMat(mat4PMv);
+ System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f"));
- m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0);
- System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4PMv, viewport, winB00, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
+ m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA00);
+ System.err.println("A.0.0 - Project 1,0 -->" + winA00);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB00); // single PMv
+ System.err.println("B.0.0 - Project 1,0 -->" + winB00);
- m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0);
- System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4PMv, viewport, winB01, vec4Tmp1, vec4Tmp2);
- System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
+ m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA01);
+ System.err.println("A.0.1 - Project 0,0 -->" + winA01);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB01); // single PMv
+ System.err.println("B.0.1 - Project 0,0 -->" + winB01);
m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
m.glOrthof(0, 10, 0, 10, 1, -1);
System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
System.err.println(m);
- m.multPMvMatrixf(mat4PMv, 0);
- System.err.println(FloatUtil.matrixToString(null, "mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
+ m.mulPMvMat(mat4PMv);
+ System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f"));
- m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0);
- System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
- FloatUtil.mapObjToWin(1f, 0f, 0f, mat4PMv, viewport, winB10, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
+ m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA10);
+ System.err.println("A.1.0 - Project 1,0 -->" +winA10);
+ Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB10); // single PMv
+ System.err.println("B.1.0 - Project 1,0 -->" +winB10);
- m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0);
- System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
- FloatUtil.mapObjToWin(0f, 0f, 0f, mat4PMv, viewport, winB11, vec4Tmp1, vec4Tmp2);
- System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
+ m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA11);
+ System.err.println("A.1.1 - Project 0,0 -->" +winA11);
+ Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB11); // single PMv
+ System.err.println("B.1.1 - Project 0,0 -->" +winB11);
- Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
- Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
- Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
- Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure", winB00, winA00);
+ Assert.assertEquals("A/B 0.1 Project 0,0 failure", winB01, winA01);
+ Assert.assertEquals("A/B 1.0 Project 1,0 failure", winB10, winA10);
+ Assert.assertEquals("A/B 1.1 Project 0,0 failure", winB11, winA11);
////////////////////
/////////////////////
@@ -87,10 +88,10 @@ public class TestPMVMatrix03NOUI extends JunitTracer {
FloatUtil.makeIdentity(modelMatrixC);
final ProjectFloat projectFloat = new ProjectFloat();
- projectFloat.gluProject(1f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport, 0, winC00, 0);
+ projectFloat.gluProject(1f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport_i4, 0, winC00, 0);
System.err.println("C.0.0 - Project 1,0 -->" +Arrays.toString(winC00));
- projectFloat.gluProject(0f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport, 0, winC01, 0);
+ projectFloat.gluProject(0f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport_i4, 0, winC01, 0);
System.err.println("C.0.1 - Project 0,0 -->" +Arrays.toString(winC01));
glOrthof(projMatrixC, 0, 10, 0, 10, 1, -1);
@@ -100,25 +101,25 @@ public class TestPMVMatrix03NOUI extends JunitTracer {
System.err.println("Modelview");
System.err.println(FloatUtil.matrixToString(null, null, "%10.5f", modelMatrixC, 0, 4, 4, false /* rowMajorOrder */));
- projectFloat.gluProject(1f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport, 0, winC10, 0);
+ projectFloat.gluProject(1f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport_i4, 0, winC10, 0);
System.err.println("C.1.0 - Project 1,0 -->" +Arrays.toString(winC10));
- projectFloat.gluProject(0f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport, 0, winC11, 0);
+ projectFloat.gluProject(0f, 0f, 0f, modelMatrixC, 0, projMatrixC, 0, viewport_i4, 0, winC11, 0);
System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winC11));
- Assert.assertArrayEquals("A/C 0.0 Project 1,0 failure", winC00, winA00, epsilon);
- Assert.assertArrayEquals("A/C 0.1 Project 0,0 failure", winC01, winA01, epsilon);
- Assert.assertArrayEquals("A/C 1.0 Project 1,0 failure", winC10, winA10, epsilon);
- Assert.assertArrayEquals("A/C 1.1 Project 0,0 failure", winC11, winA11, epsilon);
-
- Assert.assertEquals("A 0.0 Project 1,0 failure X", 10.0, winA00[0], epsilon);
- Assert.assertEquals("A 0.0 Project 1,0 failure Y", 5.0, winA00[1], epsilon);
- Assert.assertEquals("A.0.1 Project 0,0 failure X", 5.0, winA01[0], epsilon);
- Assert.assertEquals("A.0.1 Project 0,0 failure Y", 5.0, winA01[1], epsilon);
- Assert.assertEquals("A 1.0 Project 1,0 failure X", 1.0, winA10[0], epsilon);
- Assert.assertEquals("A 1.0 Project 1,0 failure Y", 0.0, winA10[1], epsilon);
- Assert.assertEquals("A.1.1 Project 0,0 failure X", 0.0, winA11[0], epsilon);
- Assert.assertEquals("A.1.1 Project 0,0 failure Y", 0.0, winA11[1], epsilon);
+ Assert.assertEquals("A/C 0.0 Project 1,0 failure", new Vec3f(winC00), winA00);
+ Assert.assertEquals("A/C 0.1 Project 0,0 failure", new Vec3f(winC01), winA01);
+ Assert.assertEquals("A/C 1.0 Project 1,0 failure", new Vec3f(winC10), winA10);
+ Assert.assertEquals("A/C 1.1 Project 0,0 failure", new Vec3f(winC11), winA11);
+
+ Assert.assertEquals("A 0.0 Project 1,0 failure X", 10.0, winA00.x(), epsilon);
+ Assert.assertEquals("A 0.0 Project 1,0 failure Y", 5.0, winA00.y(), epsilon);
+ Assert.assertEquals("A.0.1 Project 0,0 failure X", 5.0, winA01.x(), epsilon);
+ Assert.assertEquals("A.0.1 Project 0,0 failure Y", 5.0, winA01.y(), epsilon);
+ Assert.assertEquals("A 1.0 Project 1,0 failure X", 1.0, winA10.x(), epsilon);
+ Assert.assertEquals("A 1.0 Project 1,0 failure Y", 0.0, winA10.y(), epsilon);
+ Assert.assertEquals("A.1.1 Project 0,0 failure X", 0.0, winA11.x(), epsilon);
+ Assert.assertEquals("A.1.1 Project 0,0 failure Y", 0.0, winA11.y(), epsilon);
}
public final void glOrthof(final float[] m, final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java
index a9bac4f48..d2f0fc794 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java
@@ -29,7 +29,9 @@ package com.jogamp.opengl.test.junit.jogl.math;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Vec3f;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.PMVMatrix;
import org.junit.Assert;
@@ -45,49 +47,51 @@ public class TestPMVTransform01NOUI extends JunitTracer {
@Test
public void test01() {
final PMVMatrix pmv = new PMVMatrix();
- System.err.println(FloatUtil.matrixToString(null, "Ident ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+ System.err.println(pmv.getCurrentMat().toString(null, "Ident ", "%7.5f"));
- final float[] t = { 1f, 2f, 3f };
- final float[] s = { 2f, 2f, 2f };
+ final Vec3f t = new Vec3f(1f, 2f, 3f);
+ final Vec3f s = new Vec3f(2f, 2f, 2f);
- pmv.glTranslatef(t[0], t[1], t[2]);
- System.err.println(FloatUtil.matrixToString(null, "Translate ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true/* rowMajorOrder */));
- pmv.glScalef(s[0], s[1], s[2]);
- System.err.println(FloatUtil.matrixToString(null, "Scale ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+ pmv.glTranslatef(t);
+ System.err.println(pmv.getCurrentMat().toString(null, "Translate ", "%7.5f"));
+ pmv.glScalef(s);
+ System.err.println(pmv.getCurrentMat().toString(null, "Scale ", "%7.5f"));
- final float[] exp = new float[] {
+ final Matrix4f exp = new Matrix4f(new float[] {
2.00000f, 0.00000f, 0.00000f, 0.00000f,
0.00000f, 2.00000f, 0.00000f, 0.00000f,
0.00000f, 0.00000f, 2.00000f, 0.00000f,
1.00000f, 2.00000f, 3.00000f, 1.00000f,
- };
- final float[] has = new float[16];
- pmv.multPMvMatrixf(has, 0);
- Assert.assertArrayEquals(exp, has, epsilon);
+ });
+ final Matrix4f has = new Matrix4f();
+ pmv.mulPMvMat(has);
+ MiscUtils.assertMatrix4fEquals(exp, has, epsilon);
+ Assert.assertEquals(exp, has);
}
@Test
public void test02() {
final PMVMatrix pmv = new PMVMatrix();
- System.err.println(FloatUtil.matrixToString(null, "Ident ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+ System.err.println(pmv.getCurrentMat().toString(null, "Ident ", "%7.5f"));
- final float[] t = { 1f, 2f, 3f };
- final float[] s = { 2f, 2f, 2f };
+ final Vec3f t = new Vec3f(1f, 2f, 3f);
+ final Vec3f s = new Vec3f(2f, 2f, 2f);
- pmv.glScalef(s[0], s[1], s[2]);
- System.err.println(FloatUtil.matrixToString(null, "Scale ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
- pmv.glTranslatef(t[0], t[1], t[2]);
- System.err.println(FloatUtil.matrixToString(null, "Translate ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true/* rowMajorOrder */));
+ pmv.glScalef(s);
+ System.err.println(pmv.getCurrentMat().toString(null, "Scale ", "%7.5f"));
+ pmv.glTranslatef(t);
+ System.err.println(pmv.getCurrentMat().toString(null, "Translate ", "%7.5f"));
- final float[] exp = new float[] {
+ final Matrix4f exp = new Matrix4f(new float[] {
2.00000f, 0.00000f, 0.00000f, 0.00000f,
0.00000f, 2.00000f, 0.00000f, 0.00000f,
0.00000f, 0.00000f, 2.00000f, 0.00000f,
2.00000f, 4.00000f, 6.00000f, 1.00000f,
- };
- final float[] has = new float[16];
- pmv.multPMvMatrixf(has, 0);
- Assert.assertArrayEquals(exp, has, epsilon);
+ });
+ final Matrix4f has = new Matrix4f();
+ pmv.mulPMvMat(has);
+ MiscUtils.assertMatrix4fEquals(exp, has, epsilon);
+ Assert.assertEquals(exp, has);
}
public static void main(final String args[]) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java
index ecda4778d..8c6191c75 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java
@@ -28,8 +28,6 @@
package com.jogamp.opengl.test.junit.jogl.math;
-import java.util.Arrays;
-
import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
@@ -288,13 +286,13 @@ public class TestQuaternion01NOUI extends JunitTracer {
{
// quat.toMatrix(float[])
final float[] mat2_0 = new float[16];
- quat.toMatrix(mat2_0, 0);
+ quat.toMatrix(mat2_0);
Assert.assertArrayEquals(mat1_0, mat2_0, FloatUtil.EPSILON);
}
{
// quat.toMatrix(float[]) and Matrix4f.load()
final float[] mat2_0 = new float[16];
- quat.toMatrix(mat2_0, 0);
+ quat.toMatrix(mat2_0);
Assert.assertArrayEquals(mat1_0, mat2_0, FloatUtil.EPSILON);
mat2.load(mat2_0);
Assert.assertEquals(mat1, mat2);
@@ -327,7 +325,7 @@ public class TestQuaternion01NOUI extends JunitTracer {
final float[] vecHas_0 = new float[3];
vecHas.get(vecHas_0);
final float[] mat2_0 = new float[16];
- quat.toMatrix(mat2_0, 0);
+ quat.toMatrix(mat2_0);
final float[] NEG_ONE_0 = new float[3];
NEG_ONE.get(NEG_ONE_0);
final float[] vecOut3_0 = new float[3];
@@ -350,7 +348,7 @@ public class TestQuaternion01NOUI extends JunitTracer {
final float[] vecHas_0 = new float[4];
vecHas.get(vecHas_0); // w is 0
final float[] mat2_0 = new float[16];
- quat.toMatrix(mat2_0, 0);
+ quat.toMatrix(mat2_0);
final float[] NEG_ONE_v4_0 = new float[4];
NEG_ONE_v4.get(NEG_ONE_v4_0);
final float[] vecOut4_0 = new float[4];
@@ -509,13 +507,6 @@ public class TestQuaternion01NOUI extends JunitTracer {
final Vec3f eulerExp = new Vec3f ( 0f, FloatUtil.HALF_PI, 0f ); // 45 degr on X, 90 degr on Y
final Matrix4f matExp1 = new Matrix4f();
matExp1.setToRotationEuler(eulerExp.x(), eulerExp.y(), eulerExp.z());
- {
- final float[] matExp0 = new float[4*4];
- FloatUtil.makeRotationEuler(matExp0, 0, eulerExp.x(), eulerExp.y(), eulerExp.z());
- final Matrix4f matExp0b = new Matrix4f();
- matExp0b.load(matExp0);
- Assert.assertEquals(matExp0b, matExp1);
- }
final Matrix4f matHas = new Matrix4f();;
final Quaternion quat1 = new Quaternion();
@@ -545,17 +536,6 @@ public class TestQuaternion01NOUI extends JunitTracer {
final Vec3f eulerExp = new Vec3f(FloatUtil.HALF_PI, 0f, 0f);
final Matrix4f matExp = new Matrix4f();
matExp.setToRotationEuler(eulerExp.x(), eulerExp.y(), eulerExp.z()); // 45 degr on X, 90 degr on Y (?)
- {
- final float[] matExp_b0 = new float[4*4];
- FloatUtil.makeRotationEuler(matExp_b0, 0, eulerExp.x(), eulerExp.y(), eulerExp.z());
- final Matrix4f matExp_b = new Matrix4f();
- matExp_b.load(matExp_b0);
- Assert.assertEquals(matExp_b, matExp);
-
- final float[] matExp_b1 = new float[16];
- matExp.get(matExp_b1);
- Assert.assertArrayEquals(matExp_b0, matExp_b1, FloatUtil.EPSILON);
- }
final Matrix4f matHas = new Matrix4f();
final Quaternion quat1 = new Quaternion();
@@ -588,25 +568,6 @@ public class TestQuaternion01NOUI extends JunitTracer {
final Matrix4f matExp = new Matrix4f();
matExp.setToRotationEuler(eulerExp1.x(), eulerExp1.y(), eulerExp1.z());
- {
- final float[] matExp_b0 = new float[4*4];
- FloatUtil.makeRotationEuler(matExp_b0, 0, eulerExp1.x(), eulerExp1.y(), eulerExp1.z());
- final Matrix4f matExp_b = new Matrix4f();
- matExp_b.load(matExp_b0);
- Assert.assertEquals(matExp_b, matExp);
-
- final float[] matExp_b1 = new float[16];
- matExp.get(matExp_b1);
- Assert.assertArrayEquals(matExp_b0, matExp_b1, FloatUtil.EPSILON);
-
- matExp.get(matExp_b0);
- final Quaternion quat2 = new Quaternion();
- quat2.setFromMatrix(matExp);
- quat2.toMatrix(matExp_b1, 0);
- Assert.assertArrayEquals(matExp_b0, matExp_b1, FloatUtil.EPSILON);
- quat2.toMatrix(matExp_b);
- Assert.assertEquals(matExp, matExp_b);
- }
final Matrix4f matHas = new Matrix4f();
final Quaternion quat1 = new Quaternion();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
index 2d7f38423..b4226b583 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
@@ -108,7 +108,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
pmvMatrix.glTranslatef(0, 0, -2.5f);
if(null!=glM) {
glM.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- glM.glLoadMatrixf(pmvMatrix.glGetMvMatrixf());
+ glM.glLoadMatrixf(pmvMatrix.getSyncMvMat().getSyncFloats());
}
// Set location in front of camera
@@ -117,7 +117,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f);
if(null!=glM) {
glM.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- glM.glLoadMatrixf(pmvMatrix.glGetPMatrixf());
+ glM.glLoadMatrixf(pmvMatrix.getSyncPMat().getSyncFloats());
}
}
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
index d079ca56c..46c9fc2c2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java
@@ -62,6 +62,7 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
pmvMatrix = new PMVMatrix();
}
+ @Override
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -88,7 +89,7 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
sp.useProgram(gl, true);
}
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat().getSyncFloats());
if(null != st) {
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -139,6 +140,7 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
}
}
+ @Override
public void dispose(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
ims.destroy(gl);
@@ -148,6 +150,7 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
}
}
+ @Override
public void display(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -165,6 +168,7 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener {
}
// Unused routines
+ @Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
System.err.println("reshape ..");
final GL2ES2 gl = glad.getGL().getGL2ES2();
diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
index 7f35d7a86..d4c60144a 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -40,7 +40,7 @@ import java.util.Iterator;
import java.util.List;
import com.jogamp.opengl.GLContext;
-
+import com.jogamp.opengl.math.Matrix4f;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.InterruptSource;
@@ -130,7 +130,6 @@ public class MiscUtils {
}
}
}
-
public static void assertFloatBufferNotEqual(final String errmsg, final FloatBuffer expected, final FloatBuffer actual, final float delta) {
if(null == expected || null == actual) {
return;
@@ -152,6 +151,45 @@ public class MiscUtils {
throw new AssertionError(msg+"; Expected and actual are equal.");
}
+ public static void assertMatrix4fEquals(final Matrix4f expected, final Matrix4f actual, final float delta) {
+ assertMatrix4fEquals(null, expected, actual, delta);
+ }
+ public static void assertMatrix4fEquals(final String errmsg, final Matrix4f expected, final Matrix4f actual, final float delta) {
+ if(null == expected && null == actual) {
+ return;
+ }
+ final String msg = null != errmsg ? errmsg + " " : "";
+ if(null == expected) {
+ throw new AssertionError(msg+"; Expected is null, but actual not: "+actual);
+ }
+ if(null == actual) {
+ throw new AssertionError(msg+"; Actual is null, but expected not: "+expected);
+ }
+ for(int i=0; i<16; i++) {
+ final float ai = expected.get(i);
+ final float bi = actual.get(i);
+ final float daibi = Math.abs(ai - bi);
+ if( daibi > delta ) {
+ throw new AssertionError(msg+"; Expected @ ["+i+"] has "+ai+", but actual @ ["+i+"] has "+bi+", it's delta "+daibi+" > "+delta);
+ }
+ }
+ }
+ public static void assertMatrix4fNotEqual(final String errmsg, final Matrix4f expected, final Matrix4f actual, final float delta) {
+ if(null == expected || null == actual) {
+ return;
+ }
+ final String msg = null != errmsg ? errmsg + " " : "";
+ for(int i=0; i<16; i++) {
+ final float ai = expected.get(i);
+ final float bi = actual.get(i);
+ final float daibi = Math.abs(ai - bi);
+ if( daibi > delta ) {
+ return;
+ }
+ }
+ throw new AssertionError(msg+"; Expected and actual are equal.");
+ }
+
public static boolean setFieldIfExists(final Object instance, final String fieldName, final Object value) {
try {
final Field f = instance.getClass().getField(fieldName);