summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java19
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/GearsES2.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java8
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java20
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java29
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java11
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java11
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java9
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java11
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java19
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java21
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java10
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java122
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Shape.java130
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java22
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLUniformData.java153
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java769
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java232
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Quaternion.java43
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Recti.java134
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Vec2f.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Vec2i.java153
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Vec3f.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Vec4f.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java113
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java96
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java861
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/SyncAction.java47
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/SyncBuffer.java61
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f.java41
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f16.java74
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f.java42
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f16.java74
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java35
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java36
-rw-r--r--src/jogl/classes/jogamp/opengl/ProjectFloat.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java16
-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
83 files changed, 2502 insertions, 2725 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java
index 3a0955a05..5fd70f97c 100644
--- a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java
+++ b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java
@@ -63,6 +63,7 @@ import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.demos.graph.TextRendererGLELBase;
import com.jogamp.opengl.math.Matrix4f;
import com.jogamp.opengl.math.Quaternion;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.CustomGLEventListener;
import com.jogamp.opengl.util.GLArrayDataServer;
@@ -465,10 +466,10 @@ public class MovieSBSStereo implements StereoGLEventListener {
// Push the 1st uniform down the path
st.useProgram(gl, true);
- final int[] viewPort = new int[] { 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()};
+ final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
pmvMatrix = new PMVMatrix();
- reshapePMV(viewPort[2], viewPort[3]);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ reshapePMV(viewPort.width(), viewPort.height());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
@@ -494,12 +495,12 @@ public class MovieSBSStereo implements StereoGLEventListener {
{
System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]);
System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]);
- final float[] winLB = new float[3];
- final float[] winRT = new float[3];
- pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0);
- pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0);
- System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]);
- System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]);
+ final Vec3f winLB = new Vec3f();
+ final Vec3f winRT = new Vec3f();
+ pmvMatrix.gluProject(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB);
+ pmvMatrix.gluProject(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT);
+ System.err.println("XXX0: win LB: "+winLB);
+ System.err.println("XXX0: win RT: "+winRT);
}
interleavedVBOLeft = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
index 5ad6ede76..76ee32301 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
+++ b/src/demos/com/jogamp/opengl/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/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java
index 0b4dac9b2..68152ad58 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java
@@ -68,10 +68,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);
@@ -81,6 +83,7 @@ public class PointsDemoES2 extends PointsDemo {
pointParams.put(4+3, fadeThreshold);
}
+ @Override
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -109,7 +112,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);
@@ -144,6 +147,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);
@@ -183,6 +187,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();
@@ -199,6 +204,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/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java b/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java
index a6e1f5cd9..da8235c8f 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java
+++ b/src/demos/com/jogamp/opengl/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/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java
index 211ac8cbf..e9a2ad66d 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java
@@ -225,7 +225,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/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java
index 2814313c5..c556f2a2f 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java
@@ -40,6 +40,8 @@ import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLExtensions;
import com.jogamp.opengl.GLUniformData;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
@@ -163,10 +165,10 @@ public class TextureSequenceES2 implements GLEventListener {
// Push the 1st uniform down the path
st.useProgram(gl, true);
- final int[] viewPort = new int[] { 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()};
+ final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
pmvMatrix = new PMVMatrix();
- reshapePMV(viewPort[2], viewPort[3]);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ reshapePMV(viewPort.width(), viewPort.height());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
@@ -200,12 +202,12 @@ public class TextureSequenceES2 implements GLEventListener {
{
System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]);
System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]);
- final float[] winLB = new float[3];
- final float[] winRT = new float[3];
- pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0);
- pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0);
- System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]);
- System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]);
+ final Vec3f winLB = new Vec3f();
+ final Vec3f winRT = new Vec3f();
+ pmvMatrix.gluProject(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB);
+ pmvMatrix.gluProject(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT);
+ System.err.println("XXX0: win LB: "+winLB);
+ System.err.println("XXX0: win RT: "+winRT);
}
interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java
index 5bceba5eb..d02764cc0 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java
+++ b/src/demos/com/jogamp/opengl/demos/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/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java
index cab25b83d..9685f2cf9 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java
@@ -393,7 +393,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/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
index 3bf506e8f..5c65f4c29 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -47,6 +47,7 @@ import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.es2.GearsES2;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.PMVMatrix;
@@ -184,8 +185,8 @@ public class UISceneDemo01 {
static class MyPMVMatrixSetup implements PMVMatrixSetup {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float)width/(float)height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float)viewport.width()/(float)viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
@@ -196,7 +197,7 @@ public class UISceneDemo01 {
// Scale (back) to have normalized plane dimensions, 100 for the greater of width and height.
final AABBox planeBox0 = new AABBox();
- setPlaneBox(planeBox0, pmv, x, y, width, height);
+ setPlaneBox(planeBox0, pmv, viewport);
final float sx = planeBox0.getWidth();
final float sy = planeBox0.getHeight();
final float sxy = sx > sy ? sx : sy;
@@ -206,8 +207,8 @@ public class UISceneDemo01 {
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, x, y, width, height);
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
+ Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
}
};
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
index 7df78ca99..06631fdb2 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -56,6 +56,7 @@ import com.jogamp.opengl.demos.util.MiscUtils;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -199,7 +200,7 @@ public class UISceneDemo03 {
final GLProfile hasGLP = window.getChosenGLCapabilities().getGLProfile();
final AABBox sceneBox = scene.getBounds();
System.err.println("SceneBox " + sceneBox);
- System.err.println("Frustum " + scene.getMatrix().glGetFrustum());
+ System.err.println("Frustum " + scene.getMatrix().getFrustum());
final Label statusLabel;
{
@@ -421,8 +422,8 @@ public class UISceneDemo03 {
*/
public static class MyPMVMatrixSetup implements PMVMatrixSetup {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float) width / (float) height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float) viewport.width() / (float) viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
@@ -433,8 +434,8 @@ public class UISceneDemo03 {
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, x, y, width, height);
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
+ Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
}
};
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
index 0874df04e..0345515fc 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
@@ -56,6 +56,7 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.es2.GearsES2;
import com.jogamp.opengl.demos.util.MiscUtils;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -157,18 +158,18 @@ public class UISceneDemo10 {
shape.addMouseListener(new Shape.MouseGestureAdapter() {
@Override
public void mouseMoved(final MouseEvent e) {
- final int[] viewport = scene.getViewport(new int[4]);
+ final Recti viewport = scene.getViewport(new Recti());
// flip to GL window coordinates, origin bottom-left
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
testProject(scene, shape, glWinX, glWinY);
}
@Override
public void mouseDragged(final MouseEvent e) {
- final int[] viewport = scene.getViewport(new int[4]);
+ final Recti viewport = scene.getViewport(new Recti());
// flip to GL window coordinates, origin bottom-left
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
testProject(scene, shape, glWinX, glWinY);
}
} );
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index 5e94758dc..f181e51b9 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -80,6 +80,7 @@ import com.jogamp.opengl.demos.graph.MSAATool;
import com.jogamp.opengl.demos.util.MiscUtils;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -991,8 +992,8 @@ public class UISceneDemo20 implements GLEventListener {
*/
public static class MyPMVMatrixSetup implements PMVMatrixSetup {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float)width/(float)height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float)viewport.width()/(float)viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
@@ -1003,15 +1004,15 @@ public class UISceneDemo20 implements GLEventListener {
// Translate origin to bottom-left
final AABBox planeBox0 = new AABBox();
- setPlaneBox(planeBox0, pmv, x, y, width, height);
+ setPlaneBox(planeBox0, pmv, viewport);
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glTranslatef(planeBox0.getMinX(), planeBox0.getMinY(), 0f);
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, x, y, width, height);
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
+ Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
}
};
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
index fc4b275de..8e2c45431 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
@@ -44,6 +44,7 @@ import com.jogamp.opengl.GLRunnable;
import com.jogamp.opengl.demos.graph.MSAATool;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.common.util.InterruptSource;
@@ -273,21 +274,21 @@ public class UIShapeDemo01 implements GLEventListener {
float glWinX = 0;
float glWinY = 0;
final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar);
- final float[] objCoord0 = new float[3];
- final float[] objCoord1 = new float[3];
- if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord0, 0) ) {
+ final Vec3f objCoord0 = new Vec3f();
+ final Vec3f objCoord1 = new Vec3f();
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]);
+ System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord0);
}
}
glWinX = drawable.getSurfaceWidth();
glWinY = drawable.getSurfaceHeight();
- if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord1, 0) ) {
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]);
+ System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1);
}
}
- full_width_o = objCoord1[0] - objCoord0[0];
+ full_width_o = objCoord1.x() - objCoord0.x();
}
final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2);
final float full_width_s = full_width_o / txt_box_em.getWidth();
@@ -392,9 +393,9 @@ public class UIShapeDemo01 implements GLEventListener {
pmv.glTranslatef(xTran, yTran, zTran);
// flip to GL window coordinates, origin bottom-left
- final int[] viewport = renderer.getViewport(new int[4]);
+ final Recti viewport = renderer.getViewport(new Recti());
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
{
pmv.glPushMatrix();
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
index d4e7bfc0f..ed96112cd 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
@@ -68,6 +68,7 @@ import com.jogamp.opengl.demos.graph.ui.testshapes.Glyph03FreeMonoRegular_M;
import com.jogamp.opengl.demos.util.MiscUtils;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -294,22 +295,22 @@ public class UITypeDemo01 implements GLEventListener {
float glWinX = 0;
float glWinY = 0;
final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar);
- final float[] objCoord0 = new float[3];
- final float[] objCoord1 = new float[3];
- if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord0, 0) ) {
+ final Vec3f objCoord0 = new Vec3f();
+ final Vec3f objCoord1 = new Vec3f();
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]);
+ System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord0);
}
}
glWinX = drawable.getSurfaceWidth();
glWinY = drawable.getSurfaceHeight();
- if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord1, 0) ) {
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]);
+ System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1);
}
}
- full_width_o = objCoord1[0] - objCoord0[0];
- full_height_o = objCoord1[1] - objCoord0[1];
+ full_width_o = objCoord1.x() - objCoord0.x();
+ full_height_o = objCoord1.y() - objCoord0.y();
}
pmv.glPushMatrix();
@@ -462,9 +463,9 @@ public class UITypeDemo01 implements GLEventListener {
pmv.glTranslatef(xTran, yTran, zTran);
// flip to GL window coordinates, origin bottom-left
- final int[] viewport = renderer.getViewport(new int[4]);
+ final Recti viewport = renderer.getViewport(new Recti());
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
{
pmv.glPushMatrix();
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index 8174b279c..cfc8dd534 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -159,7 +159,7 @@ public class Group extends Shape implements Container {
pmv.glPushMatrix();
shape.setTransform(pmv);
- if( !doFrustumCulling || !pmv.glGetFrustum().isAABBoxOutside( shape.getBounds() ) ) {
+ if( !doFrustumCulling || !pmv.getFrustum().isAABBoxOutside( shape.getBounds() ) ) {
if( null == rgba ) {
shape.drawToSelect(gl, renderer, sampleCount);
} else {
@@ -177,8 +177,6 @@ public class Group extends Shape implements Container {
layout();
final PMVMatrix pmv = new PMVMatrix();
final AABBox tmpBox = new AABBox();
- final float[] vec3Tmp0 = new float[3];
- final float[] vec3Tmp1 = new float[3];
for(final Shape s : shapes) {
// s.validateImpl(glp, gl);
if( null != gl ) {
@@ -188,7 +186,7 @@ public class Group extends Shape implements Container {
}
pmv.glPushMatrix();
s.setTransform(pmv);
- s.getBounds().transformMv(tmpBox, pmv, vec3Tmp0, vec3Tmp0);
+ s.getBounds().transformMv(pmv, tmpBox);
pmv.glPopMatrix();
box.resize(tmpBox);
}
@@ -218,10 +216,8 @@ public class Group extends Shape implements Container {
if( null == shape ) {
return res;
}
- final float[] vec3Tmp0 = new float[3];
- final float[] vec3Tmp1 = new float[3];
forOne(pmv, shape, () -> {
- shape.getBounds().transformMv(res, pmv, vec3Tmp0, vec3Tmp1);
+ shape.getBounds().transformMv(pmv, res);
});
return res;
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index ac3bbe146..e1ee538ab 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -60,6 +60,8 @@ import com.jogamp.newt.event.GestureHandler.GestureEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Ray;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec2f;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLPixelStorageModes;
@@ -178,7 +180,7 @@ public final class Scene implements Container, GLEventListener {
/** Returns the {@link GL#glClear(int) glClear(..)} mask, see {@link #setClearParams(float[], int)}. */
public final int getClearMask() { return clearMask; }
- /** Enable or disable {@link PMVMatrix#glGetFrustum()} culling per {@link Shape}. Default is disabled. */
+ /** Enable or disable {@link PMVMatrix#getFrustum()} culling per {@link Shape}. Default is disabled. */
public final void setFrustumCullingEnabled(final boolean v) { doFrustumCulling = v; }
/** Return whether {@link #setFrustumCullingEnabled(boolean) frustum culling} is enabled. */
@@ -324,8 +326,8 @@ public final class Scene implements Container, GLEventListener {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
renderer.reshapeNotify(x, y, width, height);
- setupMatrix(renderer.getMatrix(), x, y, width, height);
- pmvMatrixSetup.setPlaneBox(planeBox, renderer.getMatrix(), x, y, width, height);
+ setupMatrix(renderer.getMatrix(), renderer.getViewport());
+ pmvMatrixSetup.setPlaneBox(planeBox, renderer.getMatrix(), renderer.getViewport());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -374,7 +376,7 @@ public final class Scene implements Container, GLEventListener {
pmv.glPushMatrix();
shape.setTransform(pmv);
- if( !doFrustumCulling || !pmv.glGetFrustum().isAABBoxOutside( shape.getBounds() ) ) {
+ if( !doFrustumCulling || !pmv.getFrustum().isAABBoxOutside( shape.getBounds() ) ) {
if( glSelect ) {
final float color = ( i + 1f ) / ( shapeCount + 2f );
// FIXME
@@ -452,7 +454,7 @@ public final class Scene implements Container, GLEventListener {
* <p>
* Method performs on current thread and returns after probing every {@link Shape}.
* </p>
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link Shape#setTransform(PMVMatrix) shape-transformed} and can be reused by the caller and runnable.
* @param glWinX window X coordinate, bottom-left origin
* @param glWinY window Y coordinate, bottom-left origin
@@ -471,7 +473,7 @@ public final class Scene implements Container, GLEventListener {
gl.glReadPixels( x, y, 1, 1, GL2ES2.GL_DEPTH_COMPONENT, GL.GL_FLOAT, winZRB);
winZ1 = winZRB.get(0); // dir
*/
- final int[] viewport = getViewport();
+ final Recti viewport = getViewport();
final Ray ray = new Ray();
shape[0] = null;
@@ -494,9 +496,6 @@ public final class Scene implements Container, GLEventListener {
});
return shape[0];
}
- private final float[] dpyTmp1V3 = new float[3];
- private final float[] dpyTmp2V3 = new float[3];
- private final float[] dpyTmp3V3 = new float[3];
/**
* Attempt to pick a {@link Shape} using the OpenGL false color rendering.
@@ -579,7 +578,7 @@ public final class Scene implements Container, GLEventListener {
* @param shape
* @param glWinX in GL window coordinates, origin bottom-left
* @param glWinY in GL window coordinates, origin bottom-left
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link Shape#setTransform(PMVMatrix) shape-transformed} and can be reused by the caller and runnable.
* @param objPos resulting object position
* @param runnable action
@@ -588,7 +587,7 @@ public final class Scene implements Container, GLEventListener {
if( null == shape ) {
return;
}
- final int[] viewport = getViewport();
+ final Recti viewport = getViewport();
setupMatrix(pmv);
forOne(pmv, shape, () -> {
if( null != shape.winToShapeCoord(pmv, viewport, glWinX, glWinY, objPos) ) {
@@ -605,7 +604,7 @@ public final class Scene implements Container, GLEventListener {
}
setupMatrix(pmv);
forOne(pmv, shape, () -> {
- shape.getBounds().transformMv(res, pmv, new float[3], new float[3]);
+ shape.getBounds().transformMv(pmv, res);
});
return res;
}
@@ -660,7 +659,7 @@ public final class Scene implements Container, GLEventListener {
}
/**
- * Interface providing {@link #set(PMVMatrix, int, int, int, int) a method} to
+ * Interface providing {@link #set(PMVMatrix, Recti) a method} to
* setup {@link PMVMatrix}'s {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}.
* <p>
* At the end of operations, the {@link GLMatrixFunc#GL_MODELVIEW} matrix has to be selected.
@@ -699,26 +698,20 @@ public final class Scene implements Container, GLEventListener {
* At the end of operations, the {@link GLMatrixFunc#GL_MODELVIEW} matrix is selected.
* </p>
* @param pmv the {@link PMVMatrix} to setup
- * @param x lower left corner of the viewport rectangle
- * @param y lower left corner of the viewport rectangle
- * @param width width of the viewport rectangle
- * @param height height of the viewport rectangle
+ * @param viewport Rect4i viewport
*/
- void set(PMVMatrix pmv, final int x, final int y, final int width, final int height);
+ void set(PMVMatrix pmv, Recti viewport);
/**
* Optional method to set the {@link Scene#getBounds()} {@link AABBox}, maybe a {@code nop} if not desired.
* <p>
- * Will be called by {@link Scene#reshape(GLAutoDrawable, int, int, int, int)} after {@link #set(PMVMatrix, int, int, int, int)}.
+ * Will be called by {@link Scene#reshape(GLAutoDrawable, int, int, int, int)} after {@link #set(PMVMatrix, Recti)}.
* </p>
* @param planeBox the {@link AABBox} to define
- * @param pmv the {@link PMVMatrix}, already setup via {@link #set(PMVMatrix, int, int, int, int)}.
- * @param x lower left corner of the viewport rectangle
- * @param y lower left corner of the viewport rectangle
- * @param width width of the viewport rectangle
- * @param height height of the viewport rectangle
+ * @param pmv the {@link PMVMatrix}, already setup via {@link #set(PMVMatrix, Recti)}.
+ * @param viewport Rect4i viewport
*/
- void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, int x, int y, final int width, final int height);
+ void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, Recti viewport);
}
/** Return the default or {@link #setPMVMatrixSetup(PMVMatrixSetup)} {@link PMVMatrixSetup}. */
@@ -732,32 +725,29 @@ public final class Scene implements Container, GLEventListener {
/**
* Setup {@link PMVMatrix} {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}
- * by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix, int, int, int, int)}.
+ * by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix, Recti)}.
* @param pmv the {@link PMVMatrix} to setup
- * @param x lower left corner of the viewport rectangle
- * @param y lower left corner of the viewport rectangle
- * @param width width of the viewport rectangle
- * @param height height of the viewport rectangle
+ * @param Recti viewport
*/
- public void setupMatrix(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- pmvMatrixSetup.set(pmv, x, y, width, height);
+ public void setupMatrix(final PMVMatrix pmv, final Recti viewport) {
+ pmvMatrixSetup.set(pmv, viewport);
}
/**
* Setup {@link PMVMatrix} {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}
- * using implicit {@link #getViewport()} surface dimension by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix, int, int, int, int)}.
+ * using implicit {@link #getViewport()} surface dimension by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix, Recti)}.
* @param pmv the {@link PMVMatrix} to setup
*/
public void setupMatrix(final PMVMatrix pmv) {
- final int[] viewport = renderer.getViewport();
- setupMatrix(pmv, viewport[0], viewport[1], viewport[2], viewport[3]);
+ final Recti viewport = renderer.getViewport();
+ setupMatrix(pmv, viewport);
}
/** Copies the current int[4] viewport in given target and returns it for chaining. It is set after initial {@link #reshape(GLAutoDrawable, int, int, int, int)}. */
- public final int[/*4*/] getViewport(final int[/*4*/] target) { return renderer.getViewport(target); }
+ public final Recti getViewport(final Recti target) { return renderer.getViewport(target); }
/** Borrows the current int[4] viewport w/o copying. It is set after initial {@link #reshape(GLAutoDrawable, int, int, int, int)}. */
- public int[/*4*/] getViewport() { return renderer.getViewport(); }
+ public Recti getViewport() { return renderer.getViewport(); }
/** Returns the {@link #getViewport()}'s width, set after initial {@link #reshape(GLAutoDrawable, int, int, int, int)}. */
public int getWidth() { return renderer.getWidth(); }
@@ -776,7 +766,7 @@ public final class Scene implements Container, GLEventListener {
* {@link AABBox#getWidth()} and {@link AABBox#getHeight()} define scene's dimension covered by surface size.
* </p>
* <p>
- * {@link AABBox} is setup via {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#setPlaneBox(AABBox, PMVMatrix, int, int, int, int)}.
+ * {@link AABBox} is setup via {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#setPlaneBox(AABBox, PMVMatrix, Recti)}.
* </p>
* <p>
* The default {@link PMVMatrixSetup} implementation scales to normalized plane dimensions, 1 for the greater of width and height.
@@ -796,12 +786,12 @@ public final class Scene implements Container, GLEventListener {
* @param objPos float[3] storage for object coord result
* @param winZ
*/
- public static void winToPlaneCoord(final PMVMatrix pmv, final int[] viewport,
+ public static void winToPlaneCoord(final PMVMatrix pmv, final Recti viewport,
final float zNear, final float zFar,
final float winX, final float winY, final float objOrthoZ,
- final float[] objPos) {
+ final Vec3f objPos) {
final float winZ = FloatUtil.getOrthoWinZ(objOrthoZ, zNear, zFar);
- pmv.gluUnProject(winX, winY, winZ, viewport, 0, objPos, 0);
+ pmv.gluUnProject(winX, winY, winZ, viewport, objPos);
}
/**
@@ -811,19 +801,19 @@ public final class Scene implements Container, GLEventListener {
* @param zNear custom {@link #DEFAULT_ZNEAR}
* @param zFar custom {@link #DEFAULT_ZFAR}
* @param objOrthoDist custom {@link #DEFAULT_SCENE_DIST}
- * @param objSceneSize float[2] storage for object surface size result
+ * @param objSceneSize Vec2f storage for object surface size result
*/
- public void surfaceToPlaneSize(final int[] viewport, final float zNear, final float zFar, final float objOrthoDist, final float[/*2*/] objSceneSize) {
+ public void surfaceToPlaneSize(final Recti viewport, final float zNear, final float zFar, final float objOrthoDist, final Vec2f objSceneSize) {
final PMVMatrix pmv = new PMVMatrix();
- setupMatrix(pmv, viewport[0], viewport[1], viewport[2], viewport[3]);
+ setupMatrix(pmv, viewport);
{
- final float[] obj00Coord = new float[3];
- final float[] obj11Coord = new float[3];
+ final Vec3f obj00Coord = new Vec3f();
+ final Vec3f obj11Coord = new Vec3f();
- winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, viewport[0], viewport[1], objOrthoDist, obj00Coord);
- winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, viewport[2], viewport[3], objOrthoDist, obj11Coord);
- objSceneSize[0] = obj11Coord[0] - obj00Coord[0];
- objSceneSize[1] = obj11Coord[1] - obj00Coord[1];
+ winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, viewport.x(), viewport.y(), objOrthoDist, obj00Coord);
+ winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, viewport.width(), viewport.height(), objOrthoDist, obj11Coord);
+ objSceneSize.set( obj11Coord.x() - obj00Coord.x(),
+ obj11Coord.y() - obj00Coord.y() );
}
}
@@ -831,9 +821,9 @@ public final class Scene implements Container, GLEventListener {
* Map given window surface-size to object coordinates relative to this scene using
* the default {@link PMVMatrixSetup}, i.e. {@link #DEFAULT_ZNEAR}, {@link #DEFAULT_ZFAR} and {@link #DEFAULT_SCENE_DIST}
* @param viewport viewport rectangle
- * @param objSceneSize float[2] storage for object surface size result
+ * @param objSceneSize Vec2f storage for object surface size result
*/
- public void surfaceToPlaneSize(final int[] viewport, final float[/*2*/] objSceneSize) {
+ public void surfaceToPlaneSize(final Recti viewport, final Vec2f objSceneSize) {
surfaceToPlaneSize(viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, -DEFAULT_SCENE_DIST, objSceneSize);
}
@@ -1090,8 +1080,8 @@ public final class Scene implements Container, GLEventListener {
private static final PMVMatrixSetup defaultPMVMatrixSetup = new PMVMatrixSetup() {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float)width/(float)height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float)viewport.width()/(float)viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(DEFAULT_ANGLE, ratio, DEFAULT_ZNEAR, DEFAULT_ZFAR);
@@ -1102,7 +1092,7 @@ public final class Scene implements Container, GLEventListener {
// Scale (back) to have normalized plane dimensions, 1 for the greater of width and height.
final AABBox planeBox0 = new AABBox();
- setPlaneBox(planeBox0, pmv, x, y, width, height);
+ setPlaneBox(planeBox0, pmv, viewport);
final float sx = planeBox0.getWidth();
final float sy = planeBox0.getHeight();
final float sxy = sx > sy ? sx : sy;
@@ -1112,21 +1102,15 @@ public final class Scene implements Container, GLEventListener {
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
final float orthoDist = -DEFAULT_SCENE_DIST;
- final float[] obj00Coord = new float[3];
- final float[] obj11Coord = new float[3];
- final int[] viewport = { x, y, width, height };
-
- winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, x, y, orthoDist, obj00Coord);
- winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, width, height, orthoDist, obj11Coord);
-
- planeBox.setSize( obj00Coord[0], // lx
- obj00Coord[1], // ly
- obj00Coord[2], // lz
- obj11Coord[0], // hx
- obj11Coord[1], // hy
- obj11Coord[2] );// hz }
+ final Vec3f obj00Coord = new Vec3f();
+ final Vec3f obj11Coord = new Vec3f();
+
+ winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, viewport.x(), viewport.y(), orthoDist, obj00Coord);
+ winToPlaneCoord(pmv, viewport, DEFAULT_ZNEAR, DEFAULT_ZFAR, viewport.width(), viewport.height(), orthoDist, obj11Coord);
+
+ planeBox.setSize( obj00Coord, obj11Coord );
}
};
private PMVMatrixSetup pmvMatrixSetup = defaultPMVMatrixSetup;
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
index 658d7848d..5e7201bdc 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
@@ -44,6 +44,7 @@ import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec2f;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
@@ -515,23 +516,20 @@ public abstract class Shape {
* @param viewport the int[4] viewport
* @param surfaceSize int[2] target surface size
* @return given int[2] {@code surfaceSize} for successful gluProject(..) operation, otherwise {@code null}
- * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], PMVMatrix, int[])
+ * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[])
* @see #getSurfaceSize(Scene, PMVMatrix, int[])
*/
- public int[/*2*/] getSurfaceSize(final PMVMatrix pmv, final int[/*4*/] viewport, final int[/*2*/] surfaceSize) {
+ public int[/*2*/] getSurfaceSize(final PMVMatrix pmv, final Recti viewport, final int[/*2*/] surfaceSize) {
// System.err.println("Shape::getSurfaceSize.VP "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]);
- final float[] winCoordHigh = new float[3];
- final float[] winCoordLow = new float[3];
+ final Vec3f winCoordHigh = new Vec3f();
+ final Vec3f winCoordLow = new Vec3f();
final Vec3f high = box.getHigh();
final Vec3f low = box.getLow();
- if( pmv.gluProject(high.x(), high.y(), high.z(), viewport, 0, winCoordHigh, 0) ) {
- // System.err.printf("Shape::surfaceSize.H: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), high[0], high[1], high[2], winCoordHigh[0], winCoordHigh[1], winCoordHigh[2]);
- if( pmv.gluProject(low.x(), low.y(), low.z(), viewport, 0, winCoordLow, 0) ) {
- // System.err.printf("Shape::surfaceSize.L: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), low[0], low[1], low[2], winCoordLow[0], winCoordLow[1], winCoordLow[2]);
- surfaceSize[0] = (int)(winCoordHigh[0] - winCoordLow[0]);
- surfaceSize[1] = (int)(winCoordHigh[1] - winCoordLow[1]);
- // System.err.printf("Shape::surfaceSize.S: shape %d: %f x %f -> %d x %d%n", getName(), winCoordHigh[0] - winCoordLow[0], winCoordHigh[1] - winCoordLow[1], surfaceSize[0], surfaceSize[1]);
+ if( pmv.gluProject(high, viewport, winCoordHigh) ) {
+ if( pmv.gluProject(low, viewport, winCoordLow) ) {
+ surfaceSize[0] = (int)(winCoordHigh.x() - winCoordLow.x());
+ surfaceSize[1] = (int)(winCoordHigh.y() - winCoordLow.y());
return surfaceSize;
}
}
@@ -541,20 +539,20 @@ public abstract class Shape {
/**
* Retrieve surface (view) size of this shape.
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
- * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} given {@link PMVMatrix} {@code pmv}.
- * @param viewport used viewport for {@link PMVMatrix#gluProject(float, float, float, int[], int, float[], int)}
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}.
+ * @param viewport used viewport for {@link PMVMatrix#gluProject(float, float, float, int[], float[])}
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param surfaceSize int[2] target surface size
* @return given int[2] {@code surfaceSize} for successful gluProject(..) operation, otherwise {@code null}
- * @see #getSurfaceSize(PMVMatrix, int[], int[])
+ * @see #getSurfaceSize(PMVMatrix, Recti, int[])
* @see #getSurfaceSize(Scene, PMVMatrix, int[])
*/
- public int[/*2*/] getSurfaceSize(final Scene.PMVMatrixSetup pmvMatrixSetup, final int[/*4*/] viewport, final PMVMatrix pmv, final int[/*2*/] surfaceSize) {
- pmvMatrixSetup.set(pmv, viewport[0], viewport[1], viewport[2], viewport[3]);
+ public int[/*2*/] getSurfaceSize(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final PMVMatrix pmv, final int[/*2*/] surfaceSize) {
+ pmvMatrixSetup.set(pmv, viewport);
setTransform(pmv);
return getSurfaceSize(pmv, viewport, surfaceSize);
}
@@ -562,16 +560,16 @@ public abstract class Shape {
/**
* Retrieve surface (view) size of this shape.
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
* @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport.
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param surfaceSize int[2] target surface size
* @return given int[2] {@code surfaceSize} for successful gluProject(..) operation, otherwise {@code null}
- * @see #getSurfaceSize(PMVMatrix, int[], int[])
- * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], PMVMatrix, int[])
+ * @see #getSurfaceSize(PMVMatrix, Recti, int[])
+ * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[])
*/
public int[/*2*/] getSurfaceSize(final Scene scene, final PMVMatrix pmv, final int[/*2*/] surfaceSize) {
return getSurfaceSize(scene.getPMVMatrixSetup(), scene.getViewport(), pmv, surfaceSize);
@@ -580,11 +578,11 @@ public abstract class Shape {
/**
* Retrieve pixel per scaled shape-coordinate unit, i.e. [px]/[obj].
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
* @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport.
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param pixPerShape float[2] pixel per scaled shape-coordinate unit result storage
* @return given float[2] {@code pixPerShape} for successful gluProject(..) operation, otherwise {@code null}
@@ -604,11 +602,11 @@ public abstract class Shape {
/**
* Retrieve pixel per scaled shape-coordinate unit, i.e. [px]/[obj].
- * @param shapeSizePx int[2] shape size in pixel as retrieved via e.g. {@link #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], PMVMatrix, int[])}
+ * @param shapeSizePx int[2] shape size in pixel as retrieved via e.g. {@link #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[])}
* @param pixPerShape float[2] pixel scaled per shape-coordinate unit result storage
* @return given float[2] {@code pixPerShape}
* @see #getPixelPerShapeUnit(Scene, PMVMatrix, float[])
- * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], PMVMatrix, int[])
+ * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[])
* @see #getScaledWidth()
* @see #getScaledHeight()
*/
@@ -626,22 +624,20 @@ public abstract class Shape {
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
* @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Scene#setupMatrix(PMVMatrix) setupMatrix(..)} and {@link #setTransform(PMVMatrix)}.
- * @param viewport the int[4] viewport
+ * @param viewport the viewport
* @param objPos object position relative to this shape's center
* @param glWinPos int[2] target window position of objPos relative to this shape
* @return given int[2] {@code glWinPos} for successful gluProject(..) operation, otherwise {@code null}
- * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], float[], PMVMatrix, int[])
+ * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, float[], PMVMatrix, int[])
* @see #shapeToWinCoord(Scene, float[], PMVMatrix, int[])
*/
- public int[/*2*/] shapeToWinCoord(final PMVMatrix pmv, final int[/*4*/] viewport, final Vec3f objPos, final int[/*2*/] glWinPos) {
+ public int[/*2*/] shapeToWinCoord(final PMVMatrix pmv, final Recti viewport, final Vec3f objPos, final int[/*2*/] glWinPos) {
// System.err.println("Shape::objToWinCoordgetSurfaceSize.VP "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]);
- final float[] winCoord = new float[3];
+ final Vec3f winCoord = new Vec3f();
- if( pmv.gluProject(objPos.x(), objPos.y(), objPos.z(), viewport, 0, winCoord, 0) ) {
- // System.err.printf("Shape::objToWinCoord.0: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), objPos[0], objPos[1], objPos[2], winCoord[0], winCoord[1], winCoord[2]);
- glWinPos[0] = (int)(winCoord[0]);
- glWinPos[1] = (int)(winCoord[1]);
- // System.err.printf("Shape::objToWinCoord.X: shape %d: %f / %f -> %d / %d%n", getName(), winCoord[0], winCoord[1], glWinPos[0], glWinPos[1]);
+ if( pmv.gluProject(objPos, viewport, winCoord) ) {
+ glWinPos[0] = (int)(winCoord.x());
+ glWinPos[1] = (int)(winCoord.y());
return glWinPos;
}
return null;
@@ -650,21 +646,21 @@ public abstract class Shape {
/**
* Map given object coordinate relative to this shape to window coordinates.
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
- * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} given {@link PMVMatrix} {@code pmv}.
- * @param viewport used viewport for {@link PMVMatrix#gluProject(float, float, float, int[], int, float[], int)}
+ * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}.
+ * @param viewport used viewport for {@link PMVMatrix#gluProject(Vec3f, Recti, Vec3f)}
* @param objPos object position relative to this shape's center
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param glWinPos int[2] target window position of objPos relative to this shape
* @return given int[2] {@code glWinPos} for successful gluProject(..) operation, otherwise {@code null}
- * @see #shapeToWinCoord(PMVMatrix, int[], float[], int[])
+ * @see #shapeToWinCoord(PMVMatrix, Recti, float[], int[])
* @see #shapeToWinCoord(Scene, float[], PMVMatrix, int[])
*/
- public int[/*2*/] shapeToWinCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final int[/*4*/] viewport, final Vec3f objPos, final PMVMatrix pmv, final int[/*2*/] glWinPos) {
- pmvMatrixSetup.set(pmv, viewport[0], viewport[1], viewport[2], viewport[3]);
+ public int[/*2*/] shapeToWinCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final Vec3f objPos, final PMVMatrix pmv, final int[/*2*/] glWinPos) {
+ pmvMatrixSetup.set(pmv, viewport);
setTransform(pmv);
return this.shapeToWinCoord(pmv, viewport, objPos, glWinPos);
}
@@ -672,17 +668,17 @@ public abstract class Shape {
/**
* Map given object coordinate relative to this shape to window coordinates.
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
* @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport.
* @param objPos object position relative to this shape's center
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param glWinPos int[2] target window position of objPos relative to this shape
* @return given int[2] {@code glWinPos} for successful gluProject(..) operation, otherwise {@code null}
- * @see #shapeToWinCoord(PMVMatrix, int[], float[], int[])
- * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], float[], PMVMatrix, int[])
+ * @see #shapeToWinCoord(PMVMatrix, Recti, float[], int[])
+ * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, float[], PMVMatrix, int[])
*/
public int[/*2*/] shapeToWinCoord(final Scene scene, final Vec3f objPos, final PMVMatrix pmv, final int[/*2*/] glWinPos) {
return this.shapeToWinCoord(scene.getPMVMatrixSetup(), scene.getViewport(), objPos, pmv, glWinPos);
@@ -696,24 +692,20 @@ public abstract class Shape {
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
* @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Scene#setupMatrix(PMVMatrix) setupMatrix(..)} and {@link #setTransform(PMVMatrix)}.
- * @param viewport the int[4] viewport
+ * @param viewport the Rect4i viewport
* @param glWinX in GL window coordinates, origin bottom-left
* @param glWinY in GL window coordinates, origin bottom-left
* @param objPos target object position of glWinX/glWinY relative to this shape
* @return given {@code objPos} for successful gluProject(..) and gluUnProject(..) operation, otherwise {@code null}
- * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], int, int, PMVMatrix, float[])
+ * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, int, int, PMVMatrix, float[])
* @see #winToShapeCoord(Scene, int, int, PMVMatrix, float[])
*/
- public Vec3f winToShapeCoord(final PMVMatrix pmv, final int[/*4*/] viewport, final int glWinX, final int glWinY, final Vec3f objPos) {
+ public Vec3f winToShapeCoord(final PMVMatrix pmv, final Recti viewport, final int glWinX, final int glWinY, final Vec3f objPos) {
final Vec3f ctr = box.getCenter();
- final float[] tmp = new float[3];
-
- if( pmv.gluProject(ctr.x(), ctr.y(), ctr.z(), viewport, 0, tmp, 0) ) {
- // System.err.printf("Shape::winToObjCoord.0: shape %d: obj [%15.10ff, %15.10ff, %15.10ff] -> win [%d / %d -> %7.2ff, %7.2ff, %7.2ff, diff %7.2ff x %7.2ff]%n", getName(), ctr[0], ctr[1], ctr[2], glWinX, glWinY, tmp[0], tmp[1], tmp[2], glWinX-tmp[0], glWinY-tmp[1]);
- final float winZ = tmp[2];
- if( pmv.gluUnProject(glWinX, glWinY, winZ, viewport, 0, objPos.get(tmp), 0) ) {
- // System.err.printf("Shape::winToObjCoord.X: shape %d: win [%d, %d, %7.2ff] -> obj [%15.10ff, %15.10ff, %15.10ff]%n", getName(), glWinX, glWinY, tmp[2], objPos[0], objPos[1], objPos[2]);
- objPos.set(tmp);
+
+ if( pmv.gluProject(ctr, viewport, objPos) ) {
+ final float winZ = objPos.z();
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, viewport, objPos) ) {
return objPos;
}
}
@@ -723,22 +715,22 @@ public abstract class Shape {
/**
* Map given gl-window-coordinates to object coordinates relative to this shape and its z-coordinate.
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
- * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} given {@link PMVMatrix} {@code pmv}.
- * @param viewport used viewport for {@link PMVMatrix#gluUnProject(float, float, float, int[], int, float[], int)}
+ * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}.
+ * @param viewport used viewport for {@link PMVMatrix#gluUnProject(float, float, float, Recti, Vec3f)}
* @param glWinX in GL window coordinates, origin bottom-left
* @param glWinY in GL window coordinates, origin bottom-left
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param objPos target object position of glWinX/glWinY relative to this shape
* @return given {@code objPos} for successful gluProject(..) and gluUnProject(..) operation, otherwise {@code null}
- * @see #winToShapeCoord(PMVMatrix, int[], int, int, float[])
+ * @see #winToShapeCoord(PMVMatrix, Recti, int, int, float[])
* @see #winToShapeCoord(Scene, int, int, PMVMatrix, float[])
*/
- public Vec3f winToShapeCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final int[/*4*/] viewport, final int glWinX, final int glWinY, final PMVMatrix pmv, final Vec3f objPos) {
- pmvMatrixSetup.set(pmv, viewport[0], viewport[1], viewport[2], viewport[3]);
+ public Vec3f winToShapeCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final int glWinX, final int glWinY, final PMVMatrix pmv, final Vec3f objPos) {
+ pmvMatrixSetup.set(pmv, viewport);
setTransform(pmv);
return this.winToShapeCoord(pmv, viewport, glWinX, glWinY, objPos);
}
@@ -746,18 +738,18 @@ public abstract class Shape {
/**
* Map given gl-window-coordinates to object coordinates relative to this shape and its z-coordinate.
* <p>
- * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) setup} properly for this shape
+ * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape
* including this shape's {@link #setTransform(PMVMatrix)}.
* </p>
* @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport.
* @param glWinX in GL window coordinates, origin bottom-left
* @param glWinY in GL window coordinates, origin bottom-left
- * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, int, int, int, int) be setup},
+ * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup},
* {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller.
* @param objPos target object position of glWinX/glWinY relative to this shape
* @return given {@code objPos} for successful gluProject(..) and gluUnProject(..) operation, otherwise {@code null}
- * @see #winToShapeCoord(PMVMatrix, int[], int, int, float[])
- * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, int[], int, int, PMVMatrix, float[])
+ * @see #winToShapeCoord(PMVMatrix, Recti, int, int, float[])
+ * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, int, int, PMVMatrix, float[])
*/
public Vec3f winToShapeCoord(final Scene scene, final int glWinX, final int glWinY, final PMVMatrix pmv, final Vec3f objPos) {
return this.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, objPos);
@@ -1182,7 +1174,7 @@ public abstract class Shape {
* @param viewport the viewport
* @param objPos object position of mouse event relative to this shape
*/
- /* pp */ final void dispatchGestureEvent(final GestureEvent e, final int glWinX, final int glWinY, final PMVMatrix pmv, final int[] viewport, final Vec3f objPos) {
+ /* pp */ final void dispatchGestureEvent(final GestureEvent e, final int glWinX, final int glWinY, final PMVMatrix pmv, final Recti viewport, final Vec3f objPos) {
if( interactive && resizable && e instanceof PinchToZoomGesture.ZoomEvent ) {
final PinchToZoomGesture.ZoomEvent ze = (PinchToZoomGesture.ZoomEvent) e;
final float pixels = ze.getDelta() * ze.getScale(); //
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index a9fca4c72..4863e97d6 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -35,6 +35,7 @@ import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLES2;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.math.Recti;
import jogamp.graph.curve.opengl.shader.AttributeNames;
import jogamp.graph.curve.opengl.shader.UniformNames;
@@ -192,25 +193,25 @@ public final class RegionRenderer {
private final GLCallback enableCallback;
private final GLCallback disableCallback;
- private final int[] viewport = new int[] { 0, 0, 0, 0 };
+ private final Recti viewport = new Recti();
private boolean initialized;
private boolean vboSupported = false;
public final boolean isInitialized() { return initialized; }
- /** Copies the current int[4] viewport in given target and returns it for chaining. */
- public final int[/*4*/] getViewport(final int[/*4*/] target) {
- System.arraycopy(viewport, 0, target, 0, 4);
+ /** Copies the current Rect4i viewport in given target and returns it for chaining. */
+ public final Recti getViewport(final Recti target) {
+ target.set(viewport);
return target;
}
- /** Borrows the current int[4] viewport w/o copying. */
- public final int[/*4*/] getViewport() {
+ /** Borrows the current Rect4i viewport w/o copying. */
+ public final Recti getViewport() {
return viewport;
}
/** Return width of current viewport */
- public final int getWidth() { return viewport[2]; }
+ public final int getWidth() { return viewport.width(); }
/** Return height of current viewport */
- public final int getHeight() { return viewport[3]; }
+ public final int getHeight() { return viewport.height(); }
/** Borrow the current {@link PMVMatrix}. */
public final PMVMatrix getMatrix() { return rs.getMatrix(); }
@@ -342,10 +343,7 @@ public final class RegionRenderer {
* No PMVMatrix operation is performed here.
*/
public final void reshapeNotify(final int x, final int y, final int width, final int height) {
- viewport[0] = x;
- viewport[1] = y;
- viewport[2] = width;
- viewport[3] = height;
+ viewport.set(x, y, width, height);
}
public final void reshapePerspective(final float angle, final int width, final int height, final float near, final float far) {
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
index aafd71d64..2f518d1cc 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -139,7 +139,7 @@ public class RenderState {
public final boolean update(final GL2ES2 gl, final RenderState rs, final boolean updateLocation, final int renderModes, final boolean pass1, final boolean throwOnError) {
if( rs.id() != rsId ) {
// Assignment of Renderstate buffers to uniforms (no copy, direct reference)
- gcu_PMVMatrix01.setData(rs.pmvMatrix.glGetPMvMatrixf());
+ gcu_PMVMatrix01.setData(rs.pmvMatrix.getSyncPMvMat());
gcu_Weight.setData(rs.weightBuffer);
gcu_ColorStatic.setData(rs.colorStaticBuffer);
rsId = rs.id();
diff --git a/src/jogl/classes/com/jogamp/opengl/GLUniformData.java b/src/jogl/classes/com/jogamp/opengl/GLUniformData.java
index 55a2e0cf1..c4cc3fe8f 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLUniformData.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLUniformData.java
@@ -1,18 +1,52 @@
-
+/**
+ * Copyright 2009-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;
-import java.nio.*;
+import java.nio.Buffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.util.SyncAction;
+import com.jogamp.opengl.util.SyncBuffer;
-public class GLUniformData {
+/**
+ * GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform.
+ */
+public final class GLUniformData {
/**
* int atom
*
* Number of objects is 1
*
+ * @param name the uniform name as used in the shader
*/
public GLUniformData(final String name, final int val) {
initScalar(name, 1, Integer.valueOf(val));
@@ -23,6 +57,7 @@ public class GLUniformData {
*
* Number of objects is 1
*
+ * @param name the uniform name as used in the shader
*/
public GLUniformData(final String name, final float val) {
initScalar(name, 1, Float.valueOf(val));
@@ -33,10 +68,12 @@ public class GLUniformData {
*
* Number of objects is calculated by data.limit()/components
*
+ * @param name the uniform name as used in the shader
* @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param data the data
*/
public GLUniformData(final String name, final int components, final IntBuffer data) {
- initBuffer(name, components, data);
+ initBuffer(name, components, data, null);
}
/**
@@ -44,14 +81,29 @@ public class GLUniformData {
*
* Number of objects is calculated by data.limit()/components
*
+ * @param name the uniform name as used in the shader
* @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param data the underlying data
*/
public GLUniformData(final String name, final int components, final FloatBuffer data) {
- initBuffer(name, components, data);
+ initBuffer(name, components, data, null);
+ }
+
+ /**
+ * Multiple IntBuffer or FloatBuffer Vector
+ *
+ * Number of objects is calculated by data.limit()/components
+ *
+ * @param name the uniform name as used in the shader
+ * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param syncBuffer {@link SyncBuffer} providing {@link SyncAction} and {@link Buffer}, allowing to sync the buffer with the underlying data, see {@link #getBuffer()}
+ */
+ public GLUniformData(final String name, final int components, final SyncBuffer syncBuffer) {
+ initBuffer(name, components, syncBuffer.getBuffer(), syncBuffer.getAction());
}
private GLUniformData(final int components, final String name) {
- initBuffer(name, components, null);
+ initBuffer(name, components, null, null);
}
public static GLUniformData creatEmptyVector(final String name, final int components) {
@@ -59,7 +111,7 @@ public class GLUniformData {
}
public static GLUniformData creatEmptyMatrix(final String name, final int rows, final int columns) {
- return new GLUniformData(name, rows, columns, null);
+ return new GLUniformData(name, rows, columns, (FloatBuffer)null);
}
/**
@@ -67,17 +119,35 @@ public class GLUniformData {
*
* Number of objects is calculated by data.limit()/(rows*columns)
*
+ * @param name the uniform name as used in the shader
* @param rows the matrix rows
* @param column the matrix column
+ * @param data the underlying data
*/
public GLUniformData(final String name, final int rows, final int columns, final FloatBuffer data) {
- initBuffer(name, rows, columns, data);
+ initBuffer(name, rows, columns, data, null);
+ }
+
+ /**
+ * Multiple FloatBuffer Matrix
+ *
+ * Number of objects is calculated by data.limit()/(rows*columns)
+ *
+ * @param name the uniform name as used in the shader
+ * @param rows the matrix rows
+ * @param column the matrix column
+ * @param syncBuffer {@link SyncBuffer} providing {@link SyncAction} and {@link Buffer}, allowing to sync the buffer with the underlying data, see {@link #getBuffer()}
+ */
+ public GLUniformData(final String name, final int rows, final int columns, final SyncBuffer syncBuffer) {
+ initBuffer(name, rows, columns, syncBuffer.getBuffer(), syncBuffer.getAction());
}
public GLUniformData setData(final int data) { initScalar(Integer.valueOf(data)); return this; }
public GLUniformData setData(final float data) { initScalar(Float.valueOf(data)); return this; }
- public GLUniformData setData(final IntBuffer data) { initBuffer(data); return this; }
- public GLUniformData setData(final FloatBuffer data) { initBuffer(data); return this; }
+
+ public GLUniformData setData(final IntBuffer data) { initBuffer(data, null); return this; }
+ public GLUniformData setData(final FloatBuffer data) { initBuffer(data, null); return this; }
+ public GLUniformData setData(final SyncBuffer syncedBuffer) { initBuffer(syncedBuffer.getBuffer(), syncedBuffer.getAction()); return this; }
public int intValue() { return ((Integer)data).intValue(); };
public float floatValue() { return ((Float)data).floatValue(); };
@@ -115,16 +185,16 @@ public class GLUniformData {
return toString(null).toString();
}
- private void initBuffer(final String name, final int rows, final int columns, final Buffer buffer) {
+ private void initBuffer(final String name, final int rows, final int columns, final Buffer buffer, final SyncAction syncAction) {
if( 2>rows || rows>4 || 2>columns || columns>4 ) {
throw new GLException("rowsXcolumns must be within [2..4]X[2..4], is: "+rows+"X"+columns);
}
this.name=name;
this.rows=rows;
this.columns=columns;
- this.isMatrix=true;
+ this.bits=BIT_MATRIX;
this.location=-1;
- initBuffer(buffer);
+ initBuffer(buffer, syncAction);
}
private void initScalar(final String name, final int components, final Object data) {
if( 1>components || components>4 ) {
@@ -133,27 +203,27 @@ public class GLUniformData {
this.name=name;
this.columns=components;
this.rows=1;
- this.isMatrix=false;
+ this.bits=0;
this.location=-1;
initScalar(data);
}
- private void initBuffer(final String name, final int components, final Buffer buffer) {
+ private void initBuffer(final String name, final int components, final Buffer buffer, final SyncAction syncAction) {
if( 1>components || components>4 ) {
throw new GLException("components must be within [1..4], is: "+components);
}
this.name=name;
this.columns=components;
this.rows=1;
- this.isMatrix=false;
+ this.bits=0;
this.location=-1;
- initBuffer(buffer);
+ initBuffer(buffer, syncAction);
}
private void initScalar(final Object data) {
if(data instanceof Buffer) {
- initBuffer((Buffer)data);
+ initBuffer((Buffer)data, null);
} else if( null != data ) {
- if(isMatrix) {
+ if( isMatrix() ) {
throw new GLException("Atom type not allowed for matrix : "+this);
}
this.count=1;
@@ -164,8 +234,9 @@ public class GLUniformData {
}
}
- private void initBuffer(final Buffer buffer) {
+ private void initBuffer(final Buffer buffer, final SyncAction syncAction) {
if( null != buffer ) {
+ this.bits |= BIT_BUFFER;
final int sz = rows*columns;
if(buffer.remaining()<sz || 0!=buffer.remaining()%sz) {
throw new GLException("remaining data buffer size invalid: buffer: "+buffer.toString()+"\n\t"+this);
@@ -176,8 +247,10 @@ public class GLUniformData {
this.count=0;
this.data=null;
}
+ this.syncAction = syncAction;
}
+ /** Return the uniform name as used in the shader */
public String getName() { return name; }
public int getLocation() { return location; }
@@ -189,7 +262,7 @@ public class GLUniformData {
public int setLocation(final int location) { this.location=location; return location; }
/**
- * Retrieves the location of the shader uniform from the linked shader program.
+ * Retrieves the location of the shader uniform with {@link #getName()} from the linked shader program.
* <p>
* No validation is performed within the implementation.
* </p>
@@ -203,26 +276,54 @@ public class GLUniformData {
return location;
}
+ /**
+ * Returns the data object.
+ * <p>
+ * In case a {@link SyncAction} has been set,
+ * it is invoked to {@link SyncAction#sync() synchronize} the object with the underlying data before returning the object.
+ * </p>
+ * @return the data object.
+ * @see SyncAction#sync()
+ */
public Object getObject() {
+ if( null != syncAction ) {
+ syncAction.sync();
+ }
return data;
}
+
+ /**
+ * Returns the data buffer.
+ * <p>
+ * In case a {@link SyncAction} has been set,
+ * it is invoked to {@link SyncAction#sync() synchronize} the buffer with the underlying data before returning the buffer.
+ * </p>
+ * @return the data buffer.
+ * @see SyncAction#sync()
+ */
public Buffer getBuffer() {
+ if( null != syncAction ) {
+ syncAction.sync();
+ }
return (data instanceof Buffer)?(Buffer)data:null;
}
- public boolean isBuffer() {
- return (data instanceof Buffer);
- }
- public boolean isMatrix() { return isMatrix; }
+
+ public boolean isMatrix() { return 0 != ( BIT_MATRIX & bits ); }
+ public boolean isBuffer() { return 0 != ( BIT_BUFFER & bits ); }
public int count() { return count; }
public int components() { return rows*columns; }
public int rows() { return rows; }
public int columns() { return columns; }
+ private static final short BIT_MATRIX = 0b0000000000000001;
+ private static final short BIT_BUFFER = 0b0000000000000010;
+
private String name;
private int location;
private int rows, columns;
private int count;
private Object data;
- private boolean isMatrix;
+ private short bits;
+ private SyncAction syncAction;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
index 9ffa3bba6..9ef09d8c5 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
@@ -35,8 +35,6 @@ import com.jogamp.opengl.GLException;
import jogamp.opengl.Debug;
import com.jogamp.common.os.Platform;
-import com.jogamp.opengl.math.geom.AABBox;
-import com.jogamp.opengl.math.geom.Frustum;
/**
* Basic Float math utility functions.
@@ -87,40 +85,12 @@ public final class FloatUtil {
//
// Matrix Ops
+ // Only a subset will remain here, try using Matrix4f and perhaps PMVMatrix, SyncMatrix4f16 or SyncMatrices4f16
//
/**
* Make matrix an identity matrix
* @param m 4x4 matrix in column-major order (also result)
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @return given matrix for chaining
- */
- public static float[] makeIdentity(final float[] m, final int m_offset) {
- m[m_offset+0+4*0] = 1f;
- m[m_offset+1+4*0] = 0f;
- m[m_offset+2+4*0] = 0f;
- m[m_offset+3+4*0] = 0f;
-
- m[m_offset+0+4*1] = 0f;
- m[m_offset+1+4*1] = 1f;
- m[m_offset+2+4*1] = 0f;
- m[m_offset+3+4*1] = 0f;
-
- m[m_offset+0+4*2] = 0f;
- m[m_offset+1+4*2] = 0f;
- m[m_offset+2+4*2] = 1f;
- m[m_offset+3+4*2] = 0f;
-
- m[m_offset+0+4*3] = 0f;
- m[m_offset+1+4*3] = 0f;
- m[m_offset+2+4*3] = 0f;
- m[m_offset+3+4*3] = 1f;
- return m;
- }
-
- /**
- * Make matrix an identity matrix
- * @param m 4x4 matrix in column-major order (also result)
* @return given matrix for chaining
*/
public static float[] makeIdentity(final float[] m) {
@@ -159,43 +129,6 @@ public final class FloatUtil {
* All matrix fields are only set if <code>initM</code> is <code>true</code>.
* </p>
* @param m 4x4 matrix in column-major order (also result)
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @param initM if true, given matrix will be initialized w/ identity matrix,
- * otherwise only the diagonal and last-row is set.
- * The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix
- * for {@link #makeScale(float[], int, boolean, float, float, float) scaling}
- * and {@link #makeTranslation(float[], int, boolean, float, float, float) translation},
- * while leaving the other fields untouched for performance reasons.
- * @return given matrix for chaining
- */
- public static float[] makeTranslation(final float[] m, final int m_offset, final boolean initM, final float tx, final float ty, final float tz) {
- if( initM ) {
- makeIdentity(m, m_offset);
- } else {
- m[m_offset+0+4*0] = 1;
- m[m_offset+1+4*1] = 1;
- m[m_offset+2+4*2] = 1;
- m[m_offset+3+4*3] = 1;
- }
- m[m_offset+0+4*3] = tx;
- m[m_offset+1+4*3] = ty;
- m[m_offset+2+4*3] = tz;
- return m;
- }
-
- /**
- * Make a translation matrix in column-major order from the given axis deltas
- * <pre>
- Translation matrix (Column Order):
- 1 0 0 0
- 0 1 0 0
- 0 0 1 0
- x y z 1
- * </pre>
- * <p>
- * All matrix fields are only set if <code>initM</code> is <code>true</code>.
- * </p>
- * @param m 4x4 matrix in column-major order (also result)
* @param initM if true, given matrix will be initialized w/ identity matrix,
* otherwise only the diagonal and last-row is set.
* The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix
@@ -232,43 +165,6 @@ public final class FloatUtil {
* All matrix fields are only set if <code>initM</code> is <code>true</code>.
* </p>
* @param m 4x4 matrix in column-major order (also result)
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @param initM if true, given matrix will be initialized w/ identity matrix,
- * otherwise only the diagonal and last-row is set.
- * The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix
- * for {@link #makeScale(float[], int, boolean, float, float, float) scaling}
- * and {@link #makeTranslation(float[], int, boolean, float, float, float) translation},
- * while leaving the other fields untouched for performance reasons.
- * @return given matrix for chaining
- */
- public static float[] makeScale(final float[] m, final int m_offset, final boolean initM, final float sx, final float sy, final float sz) {
- if( initM ) {
- makeIdentity(m, m_offset);
- } else {
- m[m_offset+0+4*3] = 0;
- m[m_offset+1+4*3] = 0;
- m[m_offset+2+4*3] = 0;
- m[m_offset+3+4*3] = 1;
- }
- m[m_offset+0+4*0] = sx;
- m[m_offset+1+4*1] = sy;
- m[m_offset+2+4*2] = sz;
- return m;
- }
-
- /**
- * Make a scale matrix in column-major order from the given axis factors
- * <pre>
- Scale matrix (Any Order):
- x 0 0 0
- 0 y 0 0
- 0 0 z 0
- 0 0 0 1
- * </pre>
- * <p>
- * All matrix fields are only set if <code>initM</code> is <code>true</code>.
- * </p>
- * @param m 4x4 matrix in column-major order (also result)
* @param initM if true, given matrix will be initialized w/ identity matrix,
* otherwise only the diagonal and last-row is set.
* The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix
@@ -293,189 +189,6 @@ public final class FloatUtil {
}
/**
- * Make a rotation matrix from the given axis and angle in radians.
- * <pre>
- Rotation matrix (Column Order):
- xx(1-c)+c xy(1-c)+zs xz(1-c)-ys 0
- xy(1-c)-zs yy(1-c)+c yz(1-c)+xs 0
- xz(1-c)+ys yz(1-c)-xs zz(1-c)+c 0
- 0 0 0 1
- * </pre>
- * <p>
- * All matrix fields are set.
- * </p>
- * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q38">Matrix-FAQ Q38</a>
- * @param m 4x4 matrix in column-major order (also result)
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @return given matrix for chaining
- */
- public static float[] makeRotationAxis(final float[] m, final int m_offset, final float angrad, float x, float y, float z, final float[] tmpVec3f) {
- final float c = cos(angrad);
- final float ic= 1.0f - c;
- final float s = sin(angrad);
-
- tmpVec3f[0]=x; tmpVec3f[1]=y; tmpVec3f[2]=z;
- VectorUtil.normalizeVec3(tmpVec3f);
- x = tmpVec3f[0]; y = tmpVec3f[1]; z = tmpVec3f[2];
-
- final float xy = x*y;
- final float xz = x*z;
- final float xs = x*s;
- final float ys = y*s;
- final float yz = y*z;
- final float zs = z*s;
- m[0+0*4+m_offset] = x*x*ic+c;
- m[1+0*4+m_offset] = xy*ic+zs;
- m[2+0*4+m_offset] = xz*ic-ys;
- m[3+0*4+m_offset] = 0;
-
- m[0+1*4+m_offset] = xy*ic-zs;
- m[1+1*4+m_offset] = y*y*ic+c;
- m[2+1*4+m_offset] = yz*ic+xs;
- m[3+1*4+m_offset] = 0;
-
- m[0+2*4+m_offset] = xz*ic+ys;
- m[1+2*4+m_offset] = yz*ic-xs;
- m[2+2*4+m_offset] = z*z*ic+c;
- m[3+2*4+m_offset] = 0;
-
- m[0+3*4+m_offset] = 0f;
- m[1+3*4+m_offset] = 0f;
- m[2+3*4+m_offset] = 0f;
- m[3+3*4+m_offset] = 1f;
-
- return m;
- }
-
- /**
- * Make a concatenated rotation matrix in column-major order from the given Euler rotation angles in radians.
- * <p>
- * The rotations are applied in the given order:
- * <ul>
- * <li>y - heading</li>
- * <li>z - attitude</li>
- * <li>x - bank</li>
- * </ul>
- * </p>
- * <p>
- * All matrix fields are set.
- * </p>
- * @param m 4x4 matrix in column-major order (also result)
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @param bankX the Euler pitch angle in radians. (rotation about the X axis)
- * @param headingY the Euler yaw angle in radians. (rotation about the Y axis)
- * @param attitudeZ the Euler roll angle in radians. (rotation about the Z axis)
- * @return given matrix for chaining
- * <p>
- * Implementation does not use Quaternion and hence is exposed to
- * <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q34">Gimbal-Lock</a>
- * </p>
- * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q36">Matrix-FAQ Q36</a>
- * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm">euclideanspace.com-eulerToMatrix</a>
- */
- public static float[] makeRotationEuler(final float[] m, final int m_offset, final float bankX, final float headingY, final float attitudeZ) {
- // Assuming the angles are in radians.
- final float ch = cos(headingY);
- final float sh = sin(headingY);
- final float ca = cos(attitudeZ);
- final float sa = sin(attitudeZ);
- final float cb = cos(bankX);
- final float sb = sin(bankX);
-
- m[0+0*4+m_offset] = ch*ca;
- m[1+0*4+m_offset] = sa;
- m[2+0*4+m_offset] = -sh*ca;
- m[3+0*4+m_offset] = 0;
-
- m[0+1*4+m_offset] = sh*sb - ch*sa*cb;
- m[1+1*4+m_offset] = ca*cb;
- m[2+1*4+m_offset] = sh*sa*cb + ch*sb;
- m[3+1*4+m_offset] = 0;
-
- m[0+2*4+m_offset] = ch*sa*sb + sh*cb;
- m[1+2*4+m_offset] = -ca*sb;
- m[2+2*4+m_offset] = -sh*sa*sb + ch*cb;
- m[3+2*4+m_offset] = 0;
-
- m[0+3*4+m_offset] = 0;
- m[1+3*4+m_offset] = 0;
- m[2+3*4+m_offset] = 0;
- m[3+3*4+m_offset] = 1;
-
- return m;
- }
-
- /**
- * Make given matrix the orthogonal matrix based on given parameters.
- * <pre>
- Ortho matrix (Column Order):
- 2/dx 0 0 0
- 0 2/dy 0 0
- 0 0 2/dz 0
- tx ty tz 1
- * </pre>
- * <p>
- * All matrix fields are only set if <code>initM</code> is <code>true</code>.
- * </p>
- * @param m 4x4 matrix in column-major order (also result)
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @param initM if true, given matrix will be initialized w/ identity matrix,
- * otherwise only the orthogonal fields are set.
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param zNear
- * @param zFar
- * @return given matrix for chaining
- */
- public static float[] makeOrtho(final float[] m, final int m_offset, final boolean initM,
- final float left, final float right,
- final float bottom, final float top,
- final float zNear, final float zFar) {
- if( initM ) {
- // m[m_offset+0+4*0] = 1f;
- m[m_offset+1+4*0] = 0f;
- m[m_offset+2+4*0] = 0f;
- m[m_offset+3+4*0] = 0f;
-
- m[m_offset+0+4*1] = 0f;
- // m[m_offset+1+4*1] = 1f;
- m[m_offset+2+4*1] = 0f;
- m[m_offset+3+4*1] = 0f;
-
- m[m_offset+0+4*2] = 0f;
- m[m_offset+1+4*2] = 0f;
- // m[m_offset+2+4*2] = 1f;
- m[m_offset+3+4*2] = 0f;
-
- // m[m_offset+0+4*3] = 0f;
- // m[m_offset+1+4*3] = 0f;
- // m[m_offset+2+4*3] = 0f;
- // m[m_offset+3+4*3] = 1f;
- }
- final float dx=right-left;
- final float dy=top-bottom;
- final float dz=zFar-zNear;
- final float tx=-1.0f*(right+left)/dx;
- final float ty=-1.0f*(top+bottom)/dy;
- final float tz=-1.0f*(zFar+zNear)/dz;
-
- m[m_offset+0+4*0] = 2.0f/dx;
-
- m[m_offset+1+4*1] = 2.0f/dy;
-
- m[m_offset+2+4*2] = -2.0f/dz;
-
- m[m_offset+0+4*3] = tx;
- m[m_offset+1+4*3] = ty;
- m[m_offset+2+4*3] = tz;
- m[m_offset+3+4*3] = 1f;
-
- return m;
- }
-
- /**
* Make given matrix the frustum matrix based on given parameters.
* <pre>
Frustum matrix (Column Order):
@@ -699,7 +412,7 @@ public final class FloatUtil {
* @param mat4Tmp temp float[16] storage
* @return given matrix <code>m</code> for chaining or <code>null</code> if either delta value is <= zero.
*/
- public static float[] makePick(final float[] m, final int m_offset,
+ public static float[] makePick(final float[] m,
final float x, final float y,
final float deltaX, final float deltaY,
final int[] viewport, final int viewport_offset,
@@ -709,13 +422,13 @@ public final class FloatUtil {
}
/* Translate and scale the picked region to the entire window */
- makeTranslation(m, m_offset, true,
+ makeTranslation(m, true,
(viewport[2+viewport_offset] - 2 * (x - viewport[0+viewport_offset])) / deltaX,
(viewport[3+viewport_offset] - 2 * (y - viewport[1+viewport_offset])) / deltaY,
0);
makeScale(mat4Tmp, true,
viewport[2+viewport_offset] / deltaX, viewport[3+viewport_offset] / deltaY, 1.0f);
- multMatrix(m, m_offset, mat4Tmp, 0);
+ multMatrix(m, mat4Tmp);
return m;
}
@@ -723,42 +436,6 @@ public final class FloatUtil {
* Transpose the given matrix.
*
* @param msrc 4x4 matrix in column-major order, the source
- * @param msrc_offset offset in given array <i>msrc</i>, i.e. start of the 4x4 matrix
- * @param mres 4x4 matrix in column-major order, the result
- * @param mres_offset offset in given array <i>mres</i>, i.e. start of the 4x4 matrix
- * @return given result matrix <i>mres</i> for chaining
- */
- public static float[] transposeMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset) {
- mres[mres_offset+0] = msrc[msrc_offset+0*4];
- mres[mres_offset+1] = msrc[msrc_offset+1*4];
- mres[mres_offset+2] = msrc[msrc_offset+2*4];
- mres[mres_offset+3] = msrc[msrc_offset+3*4];
-
- final int i4_1 = 1*4;
- mres[mres_offset+0+i4_1] = msrc[msrc_offset+1+0*4];
- mres[mres_offset+1+i4_1] = msrc[msrc_offset+1+1*4];
- mres[mres_offset+2+i4_1] = msrc[msrc_offset+1+2*4];
- mres[mres_offset+3+i4_1] = msrc[msrc_offset+1+3*4];
-
- final int i4_2 = 2*4;
- mres[mres_offset+0+i4_2] = msrc[msrc_offset+2+0*4];
- mres[mres_offset+1+i4_2] = msrc[msrc_offset+2+1*4];
- mres[mres_offset+2+i4_2] = msrc[msrc_offset+2+2*4];
- mres[mres_offset+3+i4_2] = msrc[msrc_offset+2+3*4];
-
- final int i4_3 = 3*4;
- mres[mres_offset+0+i4_3] = msrc[msrc_offset+3+0*4];
- mres[mres_offset+1+i4_3] = msrc[msrc_offset+3+1*4];
- mres[mres_offset+2+i4_3] = msrc[msrc_offset+3+2*4];
- mres[mres_offset+3+i4_3] = msrc[msrc_offset+3+3*4];
-
- return mres;
- }
-
- /**
- * Transpose the given matrix.
- *
- * @param msrc 4x4 matrix in column-major order, the source
* @param mres 4x4 matrix in column-major order, the result
* @return given result matrix <i>mres</i> for chaining
*/
@@ -792,40 +469,6 @@ public final class FloatUtil {
/**
* Returns the determinant of the given matrix
* @param m 4x4 matrix in column-major order, the source
- * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix
- * @return the matrix determinant
- */
- public static float matrixDeterminant(final float[] m, final int m_offset) {
- float a11 = m[ 1+4*1 + m_offset ];
- float a21 = m[ 2+4*1 + m_offset ];
- float a31 = m[ 3+4*1 + m_offset ];
- float a12 = m[ 1+4*2 + m_offset ];
- float a22 = m[ 2+4*2 + m_offset ];
- float a32 = m[ 3+4*2 + m_offset ];
- float a13 = m[ 1+4*3 + m_offset ];
- float a23 = m[ 2+4*3 + m_offset ];
- float a33 = m[ 3+4*3 + m_offset ];
-
- float ret = 0;
- ret += m[ 0 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31));
- a11 = m[ 1+4*0 + m_offset ];
- a21 = m[ 2+4*0 + m_offset ];
- a31 = m[ 3+4*0 + m_offset ];
- ret -= m[ 0+4*1 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31));
- a12 = m[ 1+4*1 + m_offset ];
- a22 = m[ 2+4*1 + m_offset ];
- a32 = m[ 3+4*1 + m_offset ];
- ret += m[ 0+4*2 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31));
- a13 = m[ 1+4*2 + m_offset ];
- a23 = m[ 2+4*2 + m_offset ];
- a33 = m[ 3+4*2 + m_offset ];
- ret -= m[ 0+4*3 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31));
- return ret;
- }
-
- /**
- * Returns the determinant of the given matrix
- * @param m 4x4 matrix in column-major order, the source
* @return the matrix determinant
*/
public static float matrixDeterminant(final float[] m) {
@@ -855,94 +498,6 @@ public final class FloatUtil {
ret -= m[ 0+4*3 ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31));
return ret;
}
-
- /**
- * Invert the given matrix.
- * <p>
- * Returns <code>null</code> if inversion is not possible,
- * e.g. matrix is singular due to a bad matrix.
- * </p>
- *
- * @param msrc 4x4 matrix in column-major order, the source
- * @param msrc_offset offset in given array <i>msrc</i>, i.e. start of the 4x4 matrix
- * @param mres 4x4 matrix in column-major order, the result - may be <code>msrc</code> (in-place)
- * @param mres_offset offset in given array <i>mres</i>, i.e. start of the 4x4 matrix - may be <code>msrc_offset</code> (in-place)
- * @return given result matrix <i>mres</i> for chaining if successful, otherwise <code>null</code>. See above.
- */
- public static float[] invertMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset) {
- final float scale;
- {
- float max = Math.abs(msrc[0]);
-
- for( int i = 1; i < 16; i++ ) {
- final float a = Math.abs(msrc[i]);
- if( a > max ) max = a;
- }
- if( 0 == max ) {
- return null;
- }
- scale = 1.0f/max;
- }
-
- final float a11 = msrc[0+4*0+msrc_offset]*scale;
- final float a21 = msrc[1+4*0+msrc_offset]*scale;
- final float a31 = msrc[2+4*0+msrc_offset]*scale;
- final float a41 = msrc[3+4*0+msrc_offset]*scale;
- final float a12 = msrc[0+4*1+msrc_offset]*scale;
- final float a22 = msrc[1+4*1+msrc_offset]*scale;
- final float a32 = msrc[2+4*1+msrc_offset]*scale;
- final float a42 = msrc[3+4*1+msrc_offset]*scale;
- final float a13 = msrc[0+4*2+msrc_offset]*scale;
- final float a23 = msrc[1+4*2+msrc_offset]*scale;
- final float a33 = msrc[2+4*2+msrc_offset]*scale;
- final float a43 = msrc[3+4*2+msrc_offset]*scale;
- final float a14 = msrc[0+4*3+msrc_offset]*scale;
- final float a24 = msrc[1+4*3+msrc_offset]*scale;
- final float a34 = msrc[2+4*3+msrc_offset]*scale;
- final float a44 = msrc[3+4*3+msrc_offset]*scale;
-
- final float m11 = + a22*(a33*a44 - a34*a43) - a23*(a32*a44 - a34*a42) + a24*(a32*a43 - a33*a42);
- final float m12 = -( + a21*(a33*a44 - a34*a43) - a23*(a31*a44 - a34*a41) + a24*(a31*a43 - a33*a41));
- final float m13 = + a21*(a32*a44 - a34*a42) - a22*(a31*a44 - a34*a41) + a24*(a31*a42 - a32*a41);
- final float m14 = -( + a21*(a32*a43 - a33*a42) - a22*(a31*a43 - a33*a41) + a23*(a31*a42 - a32*a41));
- final float m21 = -( + a12*(a33*a44 - a34*a43) - a13*(a32*a44 - a34*a42) + a14*(a32*a43 - a33*a42));
- final float m22 = + a11*(a33*a44 - a34*a43) - a13*(a31*a44 - a34*a41) + a14*(a31*a43 - a33*a41);
- final float m23 = -( + a11*(a32*a44 - a34*a42) - a12*(a31*a44 - a34*a41) + a14*(a31*a42 - a32*a41));
- final float m24 = + a11*(a32*a43 - a33*a42) - a12*(a31*a43 - a33*a41) + a13*(a31*a42 - a32*a41);
- final float m31 = + a12*(a23*a44 - a24*a43) - a13*(a22*a44 - a24*a42) + a14*(a22*a43 - a23*a42);
- final float m32 = -( + a11*(a23*a44 - a24*a43) - a13*(a21*a44 - a24*a41) + a14*(a21*a43 - a23*a41));
- final float m33 = + a11*(a22*a44 - a24*a42) - a12*(a21*a44 - a24*a41) + a14*(a21*a42 - a22*a41);
- final float m34 = -( + a11*(a22*a43 - a23*a42) - a12*(a21*a43 - a23*a41) + a13*(a21*a42 - a22*a41));
- final float m41 = -( + a12*(a23*a34 - a24*a33) - a13*(a22*a34 - a24*a32) + a14*(a22*a33 - a23*a32));
- final float m42 = + a11*(a23*a34 - a24*a33) - a13*(a21*a34 - a24*a31) + a14*(a21*a33 - a23*a31);
- final float m43 = -( + a11*(a22*a34 - a24*a32) - a12*(a21*a34 - a24*a31) + a14*(a21*a32 - a22*a31));
- final float m44 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31);
-
- final float det = (a11*m11 + a12*m12 + a13*m13 + a14*m14)/scale;
- if( 0 == det ) {
- return null;
- }
- final float invdet = 1.0f / det;
-
- mres[0+4*0+mres_offset] = m11 * invdet;
- mres[1+4*0+mres_offset] = m12 * invdet;
- mres[2+4*0+mres_offset] = m13 * invdet;
- mres[3+4*0+mres_offset] = m14 * invdet;
- mres[0+4*1+mres_offset] = m21 * invdet;
- mres[1+4*1+mres_offset] = m22 * invdet;
- mres[2+4*1+mres_offset] = m23 * invdet;
- mres[3+4*1+mres_offset] = m24 * invdet;
- mres[0+4*2+mres_offset] = m31 * invdet;
- mres[1+4*2+mres_offset] = m32 * invdet;
- mres[2+4*2+mres_offset] = m33 * invdet;
- mres[3+4*2+mres_offset] = m34 * invdet;
- mres[0+4*3+mres_offset] = m41 * invdet;
- mres[1+4*3+mres_offset] = m42 * invdet;
- mres[2+4*3+mres_offset] = m43 * invdet;
- mres[3+4*3+mres_offset] = m44 * invdet;
- return mres;
- }
-
/**
* Invert the given matrix.
* <p>
@@ -1087,53 +642,6 @@ public final class FloatUtil {
}
/**
- * Map object coordinates to window coordinates.
- * <p>
- * Traditional <code>gluProject</code> implementation.
- * </p>
- *
- * @param objx
- * @param objy
- * @param objz
- * @param mat4PMv [projection] x [modelview] matrix, i.e. P x Mv
- * @param viewport 4 component viewport vector
- * @param win_pos 3 component window coordinate, the result
- * @param vec4Tmp1 4 component vector for temp storage
- * @param vec4Tmp2 4 component vector for temp storage
- * @return true if successful, otherwise false (z is 1)
- */
- public static boolean mapObjToWin(final float objx, final float objy, final float objz,
- final float[/*16*/] mat4PMv,
- final int[] viewport, final float[] win_pos,
- final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) {
- vec4Tmp2[0] = objx;
- vec4Tmp2[1] = objy;
- vec4Tmp2[2] = objz;
- vec4Tmp2[3] = 1.0f;
-
- // vec4Tmp1 = P * Mv * o
- multMatrixVec(mat4PMv, vec4Tmp2, vec4Tmp1);
-
- if (vec4Tmp1[3] == 0.0f) {
- return false;
- }
-
- vec4Tmp1[3] = (1.0f / vec4Tmp1[3]) * 0.5f;
-
- // Map x, y and z to range 0-1
- vec4Tmp1[0] = vec4Tmp1[0] * vec4Tmp1[3] + 0.5f;
- vec4Tmp1[1] = vec4Tmp1[1] * vec4Tmp1[3] + 0.5f;
- vec4Tmp1[2] = vec4Tmp1[2] * vec4Tmp1[3] + 0.5f;
-
- // Map x,y to viewport
- win_pos[0] = vec4Tmp1[0] * viewport[2] + viewport[0];
- win_pos[1] = vec4Tmp1[1] * viewport[3] + viewport[1];
- win_pos[2] = vec4Tmp1[2];
-
- return true;
- }
-
- /**
* Map window coordinates to object coordinates.
* <p>
* Traditional <code>gluUnProject</code> implementation.
@@ -1201,134 +709,6 @@ public final class FloatUtil {
/**
* Map window coordinates to object coordinates.
* <p>
- * Traditional <code>gluUnProject</code> implementation.
- * </p>
- *
- * @param winx
- * @param winy
- * @param winz
- * @param mat4PMvI inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv)
- * @param viewport 4 component viewport vector
- * @param viewport_offset
- * @param obj_pos 3 component object coordinate, the result
- * @param obj_pos_offset
- * @param vec4Tmp1 4 component vector for temp storage
- * @param vec4Tmp2 4 component vector for temp storage
- * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
- */
- public static boolean mapWinToObj(final float winx, final float winy, final float winz,
- final float[/*16*/] mat4PMvI,
- final int[] viewport, final int viewport_offset,
- final float[] obj_pos, final int obj_pos_offset,
- final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) {
- vec4Tmp1[0] = winx;
- vec4Tmp1[1] = winy;
- vec4Tmp1[2] = winz;
- vec4Tmp1[3] = 1.0f;
-
- // Map x and y from window coordinates
- vec4Tmp1[0] = (vec4Tmp1[0] - viewport[0+viewport_offset]) / viewport[2+viewport_offset];
- vec4Tmp1[1] = (vec4Tmp1[1] - viewport[1+viewport_offset]) / viewport[3+viewport_offset];
-
- // Map to range -1 to 1
- vec4Tmp1[0] = vec4Tmp1[0] * 2 - 1;
- vec4Tmp1[1] = vec4Tmp1[1] * 2 - 1;
- vec4Tmp1[2] = vec4Tmp1[2] * 2 - 1;
-
- // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2
- multMatrixVec(mat4PMvI, vec4Tmp1, vec4Tmp2);
-
- if (vec4Tmp2[3] == 0.0) {
- return false;
- }
-
- vec4Tmp2[3] = 1.0f / vec4Tmp2[3];
-
- obj_pos[0+obj_pos_offset] = vec4Tmp2[0] * vec4Tmp2[3];
- obj_pos[1+obj_pos_offset] = vec4Tmp2[1] * vec4Tmp2[3];
- obj_pos[2+obj_pos_offset] = vec4Tmp2[2] * vec4Tmp2[3];
-
- return true;
- }
-
- /**
- * Map two window coordinates to two object coordinates,
- * distinguished by their z component.
- *
- * @param winx
- * @param winy
- * @param winz1
- * @param winz2
- * @param mat4PMvI inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv)
- * @param viewport 4 component viewport vector
- * @param viewport_offset
- * @param obj1_pos 3 component object coordinate, the result for winz1
- * @param obj1_pos_offset
- * @param obj2_pos 3 component object coordinate, the result for winz2
- * @param obj2_pos_offset
- * @param vec4Tmp1 4 component vector for temp storage
- * @param vec4Tmp2 4 component vector for temp storage
- * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
- */
- public static boolean mapWinToObj(final float winx, final float winy, final float winz1, final float winz2,
- final float[/*16*/] mat4PMvI, final int[] viewport,
- final Vec3f objPos1, final Vec3f objPos2,
- final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) {
- vec4Tmp1[0] = winx;
- vec4Tmp1[1] = winy;
- vec4Tmp1[3] = 1.0f;
-
- // Map x and y from window coordinates
- vec4Tmp1[0] = (vec4Tmp1[0] - viewport[0]) / viewport[2];
- vec4Tmp1[1] = (vec4Tmp1[1] - viewport[1]) / viewport[3];
-
- // Map to range -1 to 1
- vec4Tmp1[0] = vec4Tmp1[0] * 2 - 1;
- vec4Tmp1[1] = vec4Tmp1[1] * 2 - 1;
-
- //
- // winz1
- //
- vec4Tmp1[2] = winz1;
- vec4Tmp1[2] = vec4Tmp1[2] * 2 - 1;
-
- // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2
- multMatrixVec(mat4PMvI, vec4Tmp1, vec4Tmp2);
-
- if (vec4Tmp2[3] == 0.0) {
- return false;
- }
-
- vec4Tmp2[3] = 1.0f / vec4Tmp2[3];
-
- objPos1.set( vec4Tmp2[0] * vec4Tmp2[3],
- vec4Tmp2[1] * vec4Tmp2[3],
- vec4Tmp2[2] * vec4Tmp2[3] );
-
- //
- // winz2
- //
- vec4Tmp1[2] = winz2 * 2 - 1;
-
- // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2
- multMatrixVec(mat4PMvI, vec4Tmp1, vec4Tmp2);
-
- if (vec4Tmp2[3] == 0.0) {
- return false;
- }
-
- vec4Tmp2[3] = 1.0f / vec4Tmp2[3];
-
- objPos2.set( vec4Tmp2[0] * vec4Tmp2[3],
- vec4Tmp2[1] * vec4Tmp2[3],
- vec4Tmp2[2] * vec4Tmp2[3] );
-
- return true;
- }
-
- /**
- * Map window coordinates to object coordinates.
- * <p>
* Traditional <code>gluUnProject4</code> implementation.
* </p>
*
@@ -1396,57 +776,6 @@ public final class FloatUtil {
return true;
}
-
- /**
- * Map two window coordinates w/ shared X/Y and distinctive Z
- * to a {@link Ray}. The resulting {@link Ray} maybe used for <i>picking</i>
- * using a {@link AABBox#getRayIntersection(Ray, float[]) bounding box}.
- * <p>
- * Notes for picking <i>winz0</i> and <i>winz1</i>:
- * <ul>
- * <li>see {@link #getZBufferEpsilon(int, float, float)}</li>
- * <li>see {@link #getZBufferValue(int, float, float, float)}</li>
- * <li>see {@link #getOrthoWinZ(float, float, float)}</li>
- * </ul>
- * </p>
- * @param winx
- * @param winy
- * @param winz0
- * @param winz1
- * @param modelMatrix 4x4 modelview matrix
- * @param modelMatrix_offset
- * @param projMatrix 4x4 projection matrix
- * @param projMatrix_offset
- * @param viewport 4 component viewport vector
- * @param viewport_offset
- * @param ray storage for the resulting {@link Ray}
- * @param mat4Tmp1 16 component matrix for temp storage
- * @param mat4Tmp2 16 component matrix for temp storage
- * @param vec4Tmp2 4 component vector for temp storage
- * @return true if successful, otherwise false (failed to invert matrix, or becomes z is infinity)
- */
- public static boolean mapWinToRay(final float winx, final float winy, final float winz0, final float winz1,
- final float[] modelMatrix, final int modelMatrix_offset,
- final float[] projMatrix, final int projMatrix_offset,
- final int[] viewport,
- final Ray ray,
- final float[/*16*/] mat4Tmp1, final float[/*16*/] mat4Tmp2, final float[/*4*/] vec4Tmp2) {
- // mat4Tmp1 = P x Mv
- multMatrix(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, mat4Tmp1, 0);
-
- // mat4Tmp1 = Inv(P x Mv)
- if ( null == invertMatrix(mat4Tmp1, mat4Tmp1) ) {
- return false;
- }
- if( mapWinToObj(winx, winy, winz0, winz1, mat4Tmp1, viewport,
- ray.orig, ray.dir, mat4Tmp2, vec4Tmp2) ) {
- ray.dir.sub(ray.orig).normalize();
- return true;
- } else {
- return false;
- }
- }
-
/**
* Multiply matrix: [d] = [a] x [b]
* @param a 4x4 matrix in column-major order
@@ -1840,36 +1169,6 @@ public final class FloatUtil {
* @param v_out m_in * v_in, 3-component column-vector
* @return given result vector <i>v_out</i> for chaining
*/
- public static float[] multMatrixVec3(final float[] m_in, final int m_in_off,
- final float[] v_in, final float[] v_out) {
- // (one matrix row in column-major order) X (column vector)
- v_out[0] = v_in[0] * m_in[0*4+m_in_off ] + v_in[1] * m_in[1*4+m_in_off ] +
- v_in[2] * m_in[2*4+m_in_off ] + 1f * m_in[3*4+m_in_off ];
-
- final int m_in_off_1 = 1+m_in_off;
- v_out[1] = v_in[0] * m_in[0*4+m_in_off_1] + v_in[1] * m_in[1*4+m_in_off_1] +
- v_in[2] * m_in[2*4+m_in_off_1] + 1f * m_in[3*4+m_in_off_1];
-
- final int m_in_off_2 = 2+m_in_off;
- v_out[2] = v_in[0] * m_in[0*4+m_in_off_2] + v_in[1] * m_in[1*4+m_in_off_2] +
- v_in[2] * m_in[2*4+m_in_off_2] + 1f * m_in[3*4+m_in_off_2];
-
- return v_out;
- }
-
- /**
- * Affine 3f-vector transformation by 4x4 matrix
- *
- * 4x4 matrix multiplication with 3-component vector,
- * using {@code 1} for for {@code v_in[3]} and dropping {@code v_out[3]},
- * which shall be {@code 1}.
- *
- * @param m_in 4x4 matrix in column-major order
- * @param m_in_off
- * @param v_in 3-component column-vector
- * @param v_out m_in * v_in, 3-component column-vector
- * @return given result vector <i>v_out</i> for chaining
- */
public static float[] multMatrixVec3(final float[] m_in, final float[] v_in, final float[] v_out) {
// (one matrix row in column-major order) X (column vector)
v_out[0] = v_in[0] * m_in[0*4 ] + v_in[1] * m_in[1*4 ] +
@@ -2000,66 +1299,6 @@ public final class FloatUtil {
return sb;
}
- /**
- * @param sb optional passed StringBuilder instance to be used
- * @param rowPrefix optional prefix for each row
- * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter}
- * @param a 4x4 matrix in column major order (OpenGL)
- * @param aOffset offset to <code>a</code>'s current position
- * @param b 4x4 matrix in column major order (OpenGL)
- * @param bOffset offset to <code>a</code>'s current position
- * @param rows
- * @param columns
- * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
- * @return side by side representation
- */
- public static StringBuilder matrixToString(StringBuilder sb, final String rowPrefix, final String f,
- final FloatBuffer a, final int aOffset, final FloatBuffer b, final int bOffset,
- final int rows, final int columns, final boolean rowMajorOrder) {
- if(null == sb) {
- sb = new StringBuilder();
- }
- final String prefix = ( null == rowPrefix ) ? "" : rowPrefix;
- for(int i=0; i<rows; i++) {
- sb.append(prefix).append("[ ");
- matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i);
- sb.append("=?= ");
- matrixRowToString(sb, f, b, bOffset, rows, columns, rowMajorOrder, i);
- sb.append("]").append(Platform.getNewline());
- }
- return sb;
- }
-
- /**
- * @param sb optional passed StringBuilder instance to be used
- * @param rowPrefix optional prefix for each row
- * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter}
- * @param a 4x4 matrix in column major order (OpenGL)
- * @param aOffset offset to <code>a</code>'s current position
- * @param b 4x4 matrix in column major order (OpenGL)
- * @param bOffset offset to <code>a</code>'s current position
- * @param rows
- * @param columns
- * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
- * @return side by side representation
- */
- public static StringBuilder matrixToString(StringBuilder sb, final String rowPrefix, final String f,
- final float[] a, final int aOffset, final float[] b, final int bOffset,
- final int rows, final int columns, final boolean rowMajorOrder) {
- if(null == sb) {
- sb = new StringBuilder();
- }
- final String prefix = ( null == rowPrefix ) ? "" : rowPrefix;
- for(int i=0; i<rows; i++) {
- sb.append(prefix).append("[ ");
- matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i);
- sb.append("=?= ");
- matrixRowToString(sb, f, b, bOffset, rows, columns, rowMajorOrder, i);
- sb.append("]").append(Platform.getNewline());
- }
- return sb;
- }
-
//
// Scalar Ops
//
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java b/src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java
index 6f4b2f38d..a06d5cefc 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java
@@ -121,10 +121,44 @@ public class Matrix4f {
load(m, m_off);
}
+ /**
+ * Creates a new matrix based on given {@link FloatBuffer} 4x4 column major order.
+ * @param m 4x4 matrix in column-major order
+ */
+ public Matrix4f(final FloatBuffer m) {
+ load(m);
+ }
+
//
- // Write to Matrix via load(..)
+ // Write to Matrix via set(..) or load(..)
//
+ /** Sets the {@code i}th component with float {@code v} 0 <= i < 16 */
+ public void set(final int i, final float v) {
+ switch (i) {
+ case 0+4*0: m00 = v; break;
+ case 1+4*0: m10 = v; break;
+ case 2+4*0: m20 = v; break;
+ case 3+4*0: m30 = v; break;
+
+ case 0+4*1: m01 = v; break;
+ case 1+4*1: m11 = v; break;
+ case 2+4*1: m21 = v; break;
+ case 3+4*1: m31 = v; break;
+
+ case 0+4*2: m02 = v; break;
+ case 1+4*2: m12 = v; break;
+ case 2+4*2: m22 = v; break;
+ case 3+4*2: m32 = v; break;
+
+ case 0+4*3: m03 = v; break;
+ case 1+4*3: m13 = v; break;
+ case 2+4*3: m23 = v; break;
+ case 3+4*3: m33 = v; break;
+ default: throw new IndexOutOfBoundsException();
+ }
+ }
+
/**
* Set this matrix to identity.
* <pre>
@@ -242,7 +276,7 @@ public class Matrix4f {
// Read out Matrix via get(..)
//
- /** Gets the ith component, 0 <= i < 16 */
+ /** Gets the {@code i}th component, 0 <= i < 16 */
public float get(final int i) {
switch (i) {
case 0+4*0: return m00;
@@ -686,10 +720,6 @@ public class Matrix4f {
/**
* Multiply matrix: [this] = [this] x [b]
- * <p>
- * Roughly 15% slower than {@link #mul(Matrix4f, Matrix4f)}
- * Roughly 3% slower than {@link FloatUtil#multMatrix(float[], float[])}
- * </p>
* @param b 4x4 matrix
* @return this matrix for chaining
* @see #mul(Matrix4f, Matrix4f)
@@ -736,10 +766,6 @@ public class Matrix4f {
/**
* Multiply matrix: [this] = [a] x [b]
- * <p>
- * Roughly 13% faster than {@link #mul(Matrix4f)}
- * Roughly 11% faster than {@link FloatUtil#multMatrix(float[], float[])}
- * </p>
* @param a 4x4 matrix, can't be this matrix
* @param b 4x4 matrix, can't be this matrix
* @return this matrix for chaining
@@ -778,21 +804,6 @@ public class Matrix4f {
* @param v_out this * v_in
* @returns v_out for chaining
*/
- public final float[] mulVec4f(final float[/*4*/] v_in, final float[/*4*/] v_out) {
- // (one matrix row in column-major order) X (column vector)
- final float x = v_in[0], y = v_in[1], z = v_in[2], w = v_in[3];
- v_out[0] = x * m00 + y * m01 + z * m02 + w * m03;
- v_out[1] = x * m10 + y * m11 + z * m12 + w * m13;
- v_out[2] = x * m20 + y * m21 + z * m22 + w * m23;
- v_out[3] = x * m30 + y * m31 + z * m32 + w * m33;
- return v_out;
- }
-
- /**
- * @param v_in 4-component column-vector
- * @param v_out this * v_in
- * @returns v_out for chaining
- */
public final Vec4f mulVec4f(final Vec4f v_in, final Vec4f v_out) {
// (one matrix row in column-major order) X (column vector)
final float x = v_in.x(), y = v_in.y(), z = v_in.z(), w = v_in.w();
@@ -807,26 +818,6 @@ public class Matrix4f {
* Affine 3f-vector transformation by 4x4 matrix
*
* 4x4 matrix multiplication with 3-component vector,
- * using {@code 1} for for {@code v_in[3]} and dropping {@code v_out[3]},
- * which shall be {@code 1}.
- *
- * @param v_in 3-component column-vector
- * @param v_out m_in * v_in, 3-component column-vector
- * @returns v_out for chaining
- */
- public final float[] mulVec3f(final float[/*3*/] v_in, final float[/*3*/] v_out) {
- // (one matrix row in column-major order) X (column vector)
- final float x = v_in[0], y = v_in[1], z = v_in[2];
- v_out[0] = x * m00 + y * m01 + z * m02 + 1f * m03;
- v_out[1] = x * m10 + y * m11 + z * m12 + 1f * m13;
- v_out[2] = x * m20 + y * m21 + z * m22 + 1f * m23;
- return v_out;
- }
-
- /**
- * Affine 3f-vector transformation by 4x4 matrix
- *
- * 4x4 matrix multiplication with 3-component vector,
* using {@code 1} for for {@code v_in.w()} and dropping {@code v_out.w()},
* which shall be {@code 1}.
*
@@ -916,6 +907,22 @@ public class Matrix4f {
}
/**
+ * Set this matrix to scale.
+ * <pre>
+ Scale matrix (Any Order):
+ x 0 0 0
+ 0 y 0 0
+ 0 0 z 0
+ 0 0 0 1
+ * </pre>
+ * @param s scale Vec3f
+ * @return this matrix for chaining
+ */
+ public final Matrix4f setToScale(final Vec3f s) {
+ return setToScale(s.x(), s.y(), s.z());
+ }
+
+ /**
* Set this matrix to rotation from the given axis and angle in radians.
* <pre>
Rotation matrix (Column Order):
@@ -936,9 +943,8 @@ public class Matrix4f {
final float ic= 1.0f - c;
final float s = FloatUtil.sin(ang_rad);
- final float[] tmpVec3f = { x, y, z };
- VectorUtil.normalizeVec3(tmpVec3f);
- x = tmpVec3f[0]; y = tmpVec3f[1]; z = tmpVec3f[2];
+ final Vec3f tmp = new Vec3f(x, y, z).normalize();
+ x = tmp.x(); y = tmp.y(); z = tmp.z();
final float xy = x*y;
final float xz = x*z;
@@ -1043,6 +1049,31 @@ public class Matrix4f {
}
/**
+ * Set this matrix to rotation from the given Euler rotation angles in radians.
+ * <p>
+ * The rotations are applied in the given order:
+ * <ul>
+ * <li>y - heading</li>
+ * <li>z - attitude</li>
+ * <li>x - bank</li>
+ * </ul>
+ * </p>
+ * @param angradXYZ euler angle vector in radians holding x-bank, y-heading and z-attitude
+ * @return this quaternion for chaining.
+ * <p>
+ * Implementation does not use Quaternion and hence is exposed to
+ * <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q34">Gimbal-Lock</a>,
+ * consider using {@link #setToRotation(Quaternion)}.
+ * </p>
+ * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q36">Matrix-FAQ Q36</a>
+ * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm">euclideanspace.com-eulerToMatrix</a>
+ * @see #setToRotation(Quaternion)
+ */
+ public Matrix4f setToRotationEuler(final Vec3f angradXYZ) {
+ return setToRotationEuler(angradXYZ.x(), angradXYZ.y(), angradXYZ.z());
+ }
+
+ /**
* Set this matrix to rotation using the given Quaternion.
* <p>
* Implementation Details:
@@ -1055,7 +1086,7 @@ public class Matrix4f {
* @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 Matrix4f setToRotation(final Quaternion q) {
@@ -1255,7 +1286,7 @@ public class Matrix4f {
* @return this matrix for chaining
* @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear}
* @see #setToFrustum(float, float, float, float, float, float)
- * @see Frustum#updateByFovDesc(float[], int, boolean, Frustum.FovDesc)
+ * @see Frustum#updateByFovDesc(Matrix4f, com.jogamp.opengl.math.geom.Frustum.FovDesc)
*/
public Matrix4f setToPerspective(final FovHVHalves fovhv, final float zNear, final float zFar) throws IllegalArgumentException {
final FovHVHalves fovhvTan = fovhv.toTangents(); // use tangent of half-fov !
@@ -1268,11 +1299,14 @@ public class Matrix4f {
/**
* Calculate the frustum planes in world coordinates
- * using the passed float[16] as premultiplied P*MV (column major order).
+ * using this premultiplied P*MV (column major order) matrix.
* <p>
* Frustum plane's normals will point to the inside of the viewing frustum,
* as required by this class.
* </p>
+ * <p>
+ * Usually called by {@link Frustum#updateFrustumPlanes(Matrix4f)}.
+ * </p>
*/
public void updateFrustumPlanes(final Frustum frustum) {
// Left: a = m41 + m11, b = m42 + m12, c = m43 + m13, d = m44 + m14 - [1..4] column-major
@@ -1352,7 +1386,7 @@ public class Matrix4f {
}
/**
- * Make given matrix the <i>look-at</i> matrix based on given parameters.
+ * Set this matrix to the <i>look-at</i> matrix based on given parameters.
* <p>
* Consist out of two matrix multiplications:
* <pre>
@@ -1406,6 +1440,50 @@ public class Matrix4f {
return mul( tmp.setToTranslation( -eye.x(), -eye.y(), -eye.z() ) );
}
+ /**
+ * Set this matrix to the <i>pick</i> matrix based on given parameters.
+ * <p>
+ * Traditional <code>gluPickMatrix</code> implementation.
+ * </p>
+ * <p>
+ * Consist out of two matrix multiplications:
+ * <pre>
+ * <b>R</b> = <b>T</b> x <b>S</b>,
+ * with <b>T</b> for viewport translation matrix and
+ * <b>S</b> for viewport scale matrix.
+ *
+ * Result <b>R</b> can be utilized for <i>projection</i> multiplication, i.e.
+ * <b>P</b> = <b>P</b> x <b>R</b>,
+ * with <b>P</b> being the <i>projection</i> matrix.
+ * </pre>
+ * </p>
+ * <p>
+ * To effectively use the generated pick matrix for picking,
+ * call {@link #setToPick(float, float, float, float, Recti, Matrix4f) setToPick(..)}
+ * and multiply a {@link #setToPerspective(float, float, float, float) custom perspective matrix}
+ * by this pick matrix. Then you may load the result onto the perspective matrix stack.
+ * </p>
+ * @param x the center x-component of a picking region in window coordinates
+ * @param y the center y-component of a picking region in window coordinates
+ * @param deltaX the width of the picking region in window coordinates.
+ * @param deltaY the height of the picking region in window coordinates.
+ * @param viewport Rect4i viewport
+ * @param mat4Tmp temp storage
+ * @return this matrix for chaining or {@code null} if either delta value is <= zero.
+ */
+ public Matrix4f setToPick(final float x, final float y, final float deltaX, final float deltaY,
+ final Recti viewport, final Matrix4f mat4Tmp) {
+ if (deltaX <= 0 || deltaY <= 0) {
+ return null;
+ }
+ /* Translate and scale the picked region to the entire window */
+ setToTranslation( ( viewport.width() - 2 * ( x - viewport.x() ) ) / deltaX,
+ ( viewport.height() - 2 * ( y - viewport.y() ) ) / deltaY,
+ 0);
+ mat4Tmp.setToScale( viewport.width() / deltaX, viewport.height() / deltaY, 1.0f );
+ return mul(mat4Tmp);
+ }
+
//
// Matrix affine operations using setTo..()
//
@@ -1587,12 +1665,12 @@ public class Matrix4f {
* @param obj object position, 3 component vector
* @param mMv modelview matrix
* @param mP projection matrix
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport
* @param winPos 3 component window coordinate, the result
* @return true if successful, otherwise false (z is 1)
*/
public static boolean mapObjToWin(final Vec3f obj, final Matrix4f mMv, final Matrix4f mP,
- final int[] viewport, final float[] winPos)
+ final Recti viewport, final Vec3f winPos)
{
final Vec4f vec4Tmp1 = new Vec4f(obj, 1f);
@@ -1613,9 +1691,9 @@ public class Matrix4f {
rawWinPos.scale(s).add(0.5f, 0.5f, 0.5f, 0f);
// Map x,y to viewport
- winPos[0] = rawWinPos.x() * viewport[2] + viewport[0];
- winPos[1] = rawWinPos.y() * viewport[3] + viewport[1];
- winPos[2] = rawWinPos.z();
+ winPos.set( rawWinPos.x() * viewport.width() + viewport.x(),
+ rawWinPos.y() * viewport.height() + viewport.y(),
+ rawWinPos.z() );
return true;
}
@@ -1628,12 +1706,12 @@ public class Matrix4f {
*
* @param obj object position, 3 component vector
* @param mPMv [projection] x [modelview] matrix, i.e. P x Mv
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport
* @param winPos 3 component window coordinate, the result
* @return true if successful, otherwise false (z is 1)
*/
public static boolean mapObjToWin(final Vec3f obj, final Matrix4f mPMv,
- final int[] viewport, final float[] winPos)
+ final Recti viewport, final Vec3f winPos)
{
final Vec4f vec4Tmp2 = new Vec4f(obj, 1f);
@@ -1650,9 +1728,9 @@ public class Matrix4f {
rawWinPos.scale(s).add(0.5f, 0.5f, 0.5f, 0f);
// Map x,y to viewport
- winPos[0] = rawWinPos.x() * viewport[2] + viewport[0];
- winPos[1] = rawWinPos.y() * viewport[3] + viewport[1];
- winPos[2] = rawWinPos.z();
+ winPos.set( rawWinPos.x() * viewport.width() + viewport.x(),
+ rawWinPos.y() * viewport.height() + viewport.y(),
+ rawWinPos.z() );
return true;
}
@@ -1668,14 +1746,14 @@ public class Matrix4f {
* @param winz
* @param mMv 4x4 modelview matrix
* @param mP 4x4 projection matrix
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport
* @param objPos 3 component object coordinate, the result
* @param mat4Tmp 16 component matrix for temp storage
* @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
*/
public static boolean mapWinToObj(final float winx, final float winy, final float winz,
final Matrix4f mMv, final Matrix4f mP,
- final int[] viewport,
+ final Recti viewport,
final Vec3f objPos,
final Matrix4f mat4Tmp)
{
@@ -1688,7 +1766,7 @@ public class Matrix4f {
final Vec4f winPos = new Vec4f(winx, winy, winz, 1f);
// Map x and y from window coordinates
- winPos.add(-viewport[0], -viewport[1], 0f, 0f).scale(1f/viewport[2], 1f/viewport[3], 1f, 1f);
+ winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f, 1f);
// Map to range -1 to 1
winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f);
@@ -1714,21 +1792,21 @@ public class Matrix4f {
* @param winy
* @param winz
* @param invPMv inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv)
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport
* @param objPos 3 component object coordinate, the result
* @param mat4Tmp 16 component matrix for temp storage
* @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
*/
public static boolean mapWinToObj(final float winx, final float winy, final float winz,
final Matrix4f invPMv,
- final int[] viewport,
+ final Recti viewport,
final Vec3f objPos,
final Matrix4f mat4Tmp)
{
final Vec4f winPos = new Vec4f(winx, winy, winz, 1f);
// Map x and y from window coordinates
- winPos.add(-viewport[0], -viewport[1], 0f, 0f).scale(1f/viewport[2], 1f/viewport[3], 1f, 1f);
+ winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f, 1f);
// Map to range -1 to 1
winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f);
@@ -1756,21 +1834,21 @@ public class Matrix4f {
* @param winz1
* @param winz2
* @param invPMv inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv)
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport vector
* @param objPos1 3 component object coordinate, the result
* @param mat4Tmp 16 component matrix for temp storage
* @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
*/
public static boolean mapWinToObj(final float winx, final float winy, final float winz1, final float winz2,
final Matrix4f invPMv,
- final int[] viewport,
+ final Recti viewport,
final Vec3f objPos1, final Vec3f objPos2,
final Matrix4f mat4Tmp)
{
final Vec4f winPos = new Vec4f(winx, winy, winz1, 1f);
// Map x and y from window coordinates
- winPos.add(-viewport[0], -viewport[1], 0f, 0f).scale(1f/viewport[2], 1f/viewport[3], 1f, 1f);
+ winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f, 1f);
// Map to range -1 to 1
winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f);
@@ -1812,7 +1890,7 @@ public class Matrix4f {
* @param clipw
* @param mMv 4x4 modelview matrix
* @param mP 4x4 projection matrix
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport vector
* @param near
* @param far
* @param obj_pos 4 component object coordinate, the result
@@ -1821,7 +1899,7 @@ public class Matrix4f {
*/
public static boolean mapWinToObj4(final float winx, final float winy, final float winz, final float clipw,
final Matrix4f mMv, final Matrix4f mP,
- final int[] viewport,
+ final Recti viewport,
final float near, final float far,
final Vec4f objPos,
final Matrix4f mat4Tmp)
@@ -1835,7 +1913,7 @@ public class Matrix4f {
final Vec4f winPos = new Vec4f(winx, winy, winz, clipw);
// Map x and y from window coordinates
- winPos.add(-viewport[0], -viewport[1], -near, 0f).scale(1f/viewport[2], 1f/viewport[3], 1f/(far-near), 1f);
+ winPos.add(-viewport.x(), -viewport.y(), -near, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f/(far-near), 1f);
// Map to range -1 to 1
winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f);
@@ -1852,7 +1930,7 @@ public class Matrix4f {
/**
* Map two window coordinates w/ shared X/Y and distinctive Z
* to a {@link Ray}. The resulting {@link Ray} maybe used for <i>picking</i>
- * using a {@link AABBox#getRayIntersection(Ray, float[]) bounding box}.
+ * using a {@link AABBox#getRayIntersection(Vec3f, Ray, float, boolean)}.
* <p>
* Notes for picking <i>winz0</i> and <i>winz1</i>:
* <ul>
@@ -1867,7 +1945,7 @@ public class Matrix4f {
* @param winz1
* @param mMv 4x4 modelview matrix
* @param mP 4x4 projection matrix
- * @param viewport 4 component viewport vector
+ * @param viewport Rect4i viewport
* @param ray storage for the resulting {@link Ray}
* @param mat4Tmp1 16 component matrix for temp storage
* @param mat4Tmp2 16 component matrix for temp storage
@@ -1876,7 +1954,7 @@ public class Matrix4f {
public static boolean mapWinToRay(final float winx, final float winy, final float winz0, final float winz1,
final Matrix4f mMv,
final Matrix4f mP,
- final int[] viewport,
+ final Recti viewport,
final Ray ray,
final Matrix4f mat4Tmp1, final Matrix4f mat4Tmp2) {
// invPMv = Inv(P x Mv)
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
index 2bb0f96c6..a285774f8 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
@@ -1000,18 +1000,17 @@ public class Quaternion {
* </p>
*
* @param matrix float[16] store for the resulting normalized column matrix 4x4
- * @param mat_offset
* @return the given matrix store
* @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54">Matrix-FAQ Q54</a>
* @see #setFromMatrix(Matrix4f)
* @see #setFromMatrix(float, float, float, float, float, float, float, float, float)
*/
- public final float[] toMatrix(final float[] matrix, final int mat_offset) {
+ public final float[] toMatrix(final float[] matrix) {
// pre-multiply scaled-reciprocal-magnitude to reduce multiplications
final float norm = magnitudeSquared();
if ( FloatUtil.isZero(norm, FloatUtil.EPSILON) ) {
// identity matrix -> srecip = 0f
- return FloatUtil.makeIdentity(matrix, mat_offset);
+ return FloatUtil.makeIdentity(matrix);
}
final float srecip;
if ( FloatUtil.isEqual(1f, norm, FloatUtil.EPSILON) ) {
@@ -1034,25 +1033,25 @@ public class Quaternion {
final float zz = z * zs;
final float zw = zs * w;
- matrix[0+0*4+mat_offset] = 1f - ( yy + zz );
- matrix[0+1*4+mat_offset] = ( xy - zw );
- matrix[0+2*4+mat_offset] = ( xz + yw );
- matrix[0+3*4+mat_offset] = 0f;
-
- matrix[1+0*4+mat_offset] = ( xy + zw );
- matrix[1+1*4+mat_offset] = 1f - ( xx + zz );
- matrix[1+2*4+mat_offset] = ( yz - xw );
- matrix[1+3*4+mat_offset] = 0f;
-
- matrix[2+0*4+mat_offset] = ( xz - yw );
- matrix[2+1*4+mat_offset] = ( yz + xw );
- matrix[2+2*4+mat_offset] = 1f - ( xx + yy );
- matrix[2+3*4+mat_offset] = 0f;
-
- matrix[3+0*4+mat_offset] = 0f;
- matrix[3+1*4+mat_offset] = 0f;
- matrix[3+2*4+mat_offset] = 0f;
- matrix[3+3*4+mat_offset] = 1f;
+ matrix[0+0*4] = 1f - ( yy + zz );
+ matrix[0+1*4] = ( xy - zw );
+ matrix[0+2*4] = ( xz + yw );
+ matrix[0+3*4] = 0f;
+
+ matrix[1+0*4] = ( xy + zw );
+ matrix[1+1*4] = 1f - ( xx + zz );
+ matrix[1+2*4] = ( yz - xw );
+ matrix[1+3*4] = 0f;
+
+ matrix[2+0*4] = ( xz - yw );
+ matrix[2+1*4] = ( yz + xw );
+ matrix[2+2*4] = 1f - ( xx + yy );
+ matrix[2+3*4] = 0f;
+
+ matrix[3+0*4] = 0f;
+ matrix[3+1*4] = 0f;
+ matrix[3+2*4] = 0f;
+ matrix[3+3*4] = 1f;
return matrix;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Recti.java b/src/jogl/classes/com/jogamp/opengl/math/Recti.java
new file mode 100644
index 000000000..58f5e5e77
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/math/Recti.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright 2022-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.math;
+
+/**
+ * Rectangle with x, y, width and height integer components.
+ */
+public final class Recti {
+ private int x;
+ private int y;
+ private int width;
+ private int height;
+
+ public Recti() {}
+
+ public Recti(final Recti o) {
+ set(o);
+ }
+
+ public Recti copy() {
+ return new Recti(this);
+ }
+
+ public Recti(final int[/*4*/] xywh) {
+ set(xywh);
+ }
+
+ public Recti(final int x, final int y, final int width, final int height) {
+ set(x, y, width, height);
+ }
+
+ /** this = o, returns this. */
+ public void set(final Recti o) {
+ this.x = o.x;
+ this.y = o.y;
+ this.width = o.width;
+ this.height= o.height;
+ }
+
+ /** this = { x, y, width, height }, returns this. */
+ public void set(final int x, final int y, final int width, final int height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height= height;
+ }
+
+ /** this = xywh, returns this. */
+ public Recti set(final int[/*2*/] xywh) {
+ this.x = xywh[0];
+ this.y = xywh[1];
+ this.width = xywh[2];
+ this.height= xywh[3];
+ return this;
+ }
+
+ /** xywh = this, returns xy. */
+ public int[] get(final int[/*4*/] xywh) {
+ xywh[0] = this.x;
+ xywh[1] = this.y;
+ xywh[2] = this.width;
+ xywh[3] = this.height;
+ return xywh;
+ }
+
+ public int x() { return x; }
+ public int y() { return y; }
+ public int width() { return width; }
+ public int height() { return height; }
+
+ public void setX(final int x) { this.x = x; }
+ public void setY(final int y) { this.y = y; }
+ public void setWidth(final int width) { this.width = width; }
+ public void setHeight(final int height) { this.height = height; }
+
+ /** Return true if all components are zero. */
+ public boolean isZero() {
+ return 0 == x && 0 == y;
+ }
+
+ /**
+ * Equals check.
+ * @param o comparison value
+ * @return true if all components are equal
+ */
+ public boolean isEqual(final Recti o) {
+ if( this == o ) {
+ return true;
+ } else {
+ return x == o.x && y == o.y &&
+ width == o.width && height == o.height;
+ }
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if( o instanceof Recti ) {
+ return isEqual((Recti)o);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return x + " / " + y + " " + width + " x " + height;
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java
index 0c7854216..616ba0f60 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java
@@ -301,13 +301,6 @@ public final class Vec2f {
return new Vec2f(-y, x);
}
- public boolean intersects(final Vec2f o) {
- if( Math.abs(x-o.x) >= FloatUtil.EPSILON || Math.abs(y-o.y) >= FloatUtil.EPSILON ) {
- return false;
- }
- return true;
- }
-
/**
* Equals check using a given {@link FloatUtil#EPSILON} value and {@link FloatUtil#isEqual(float, float, float)}.
* <p>
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec2i.java b/src/jogl/classes/com/jogamp/opengl/math/Vec2i.java
new file mode 100644
index 000000000..9e70a502f
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vec2i.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright 2022-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.math;
+
+/**
+ * 2D Vector based upon two integer components.
+ */
+public final class Vec2i {
+ private int x;
+ private int y;
+
+ public Vec2i() {}
+
+ public Vec2i(final Vec2i o) {
+ set(o);
+ }
+
+ public Vec2i copy() {
+ return new Vec2i(this);
+ }
+
+ public Vec2i(final int[/*2*/] xy) {
+ set(xy);
+ }
+
+ public Vec2i(final int x, final int y) {
+ set(x, y);
+ }
+
+ /** this = o, returns this. */
+ public void set(final Vec2i o) {
+ this.x = o.x;
+ this.y = o.y;
+ }
+
+ /** this = { x, y }, returns this. */
+ public void set(final int x, final int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** this = xy, returns this. */
+ public Vec2i set(final int[/*2*/] xy) {
+ this.x = xy[0];
+ this.y = xy[1];
+ return this;
+ }
+
+ /** xy = this, returns xy. */
+ public int[] get(final int[/*2*/] xy) {
+ xy[0] = this.x;
+ xy[1] = this.y;
+ return xy;
+ }
+
+ public int x() { return x; }
+ public int y() { return y; }
+
+ public void setX(final int x) { this.x = x; }
+ public void setY(final int y) { this.y = y; }
+
+ /** Return true if all components are zero. */
+ public boolean isZero() {
+ return 0 == x && 0 == y;
+ }
+
+ /**
+ * Return the length of this vector, a.k.a the <i>norm</i> or <i>magnitude</i>
+ */
+ public int length() {
+ return (int) Math.sqrt(lengthSq());
+ }
+
+ /**
+ * Return the squared length of this vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i>
+ */
+ public int lengthSq() {
+ return x*x + y*y;
+ }
+
+ /**
+ * Return the squared distance between this vector and the given one.
+ * <p>
+ * When comparing the relative distance between two points it is usually sufficient to compare the squared
+ * distances, thus avoiding an expensive square root operation.
+ * </p>
+ */
+ public int distSq(final Vec2i o) {
+ final int dx = x - o.x;
+ final int dy = y - o.y;
+ return dx*dx + dy*dy;
+ }
+
+ /**
+ * Return the distance between this vector and the given one.
+ */
+ public int dist(final Vec2i o) {
+ return (int)Math.sqrt(distSq(o));
+ }
+
+ /**
+ * Equals check.
+ * @param o comparison value
+ * @return true if all components are equal
+ */
+ public boolean isEqual(final Vec2i o) {
+ if( this == o ) {
+ return true;
+ } else {
+ return x == o.x && y == o.y;
+ }
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if( o instanceof Vec2i ) {
+ return isEqual((Vec2i)o);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return x + " / " + y;
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java
index d5c725ad7..9ef985b36 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java
@@ -312,14 +312,6 @@ public final class Vec3f {
return (float) Math.acos( cosAngle(o) );
}
- public boolean intersects(final Vec3f o) {
- if( Math.abs(x-o.x) >= FloatUtil.EPSILON || Math.abs(y-o.y) >= FloatUtil.EPSILON || Math.abs(z-o.z) >= FloatUtil.EPSILON ) {
- return false;
- } else {
- return true;
- }
- }
-
/**
* Equals check using a given {@link FloatUtil#EPSILON} value and {@link FloatUtil#isEqual(float, float, float)}.
* <p>
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java
index 1a20015a9..570b7b2b3 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java
@@ -284,14 +284,6 @@ public final class Vec4f {
return (float) Math.acos( cosAngle(o) );
}
- public boolean intersects(final Vec4f o) {
- if( Math.abs(x-o.x) >= FloatUtil.EPSILON || Math.abs(y-o.y) >= FloatUtil.EPSILON || Math.abs(z-o.z) >= FloatUtil.EPSILON ||
- Math.abs(w-o.w) >= FloatUtil.EPSILON) {
- return false;
- }
- return true;
- }
-
/**
* Equals check using a given {@link FloatUtil#EPSILON} value and {@link FloatUtil#isEqual(float, float, float)}.
* <p>
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
index 77e1bfc59..ad521de2a 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
@@ -32,6 +32,7 @@ import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Matrix4f;
import com.jogamp.opengl.math.Quaternion;
import com.jogamp.opengl.math.Ray;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.PMVMatrix;
@@ -718,41 +719,34 @@ public class AABBox {
throw new InternalError("hashCode not designed");
}
- public AABBox transform(final AABBox result, final float[/*16*/] mat4, final int mat4_off,
- final float[] vec3Tmp0, final float[] vec3Tmp1) {
- result.reset();
- FloatUtil.multMatrixVec3(mat4, mat4_off, low.get(vec3Tmp0), vec3Tmp1);
- result.resize(vec3Tmp1);
-
- FloatUtil.multMatrixVec3(mat4, mat4_off, high.get(vec3Tmp0), vec3Tmp1);
- result.resize(vec3Tmp1);
-
- result.computeCenter();
- return result;
- }
-
- public AABBox transformMv(final AABBox result, final PMVMatrix pmv,
- final float[] vec3Tmp0, final float[] vec3Tmp1) {
- result.reset();
- pmv.multMvMatVec3f(low.get(vec3Tmp0), vec3Tmp1);
- result.resize(vec3Tmp1);
-
- pmv.multMvMatVec3f(high.get(vec3Tmp0), vec3Tmp1);
- result.resize(vec3Tmp1);
-
- result.computeCenter();
- return result;
+ /**
+ * Transform this box using the given {@link Matrix4f} into {@code out}
+ * @param mat transformation {@link Matrix4f}
+ * @param out the resulting {@link AABBox}
+ * @return the resulting {@link AABBox} for chaining
+ */
+ public AABBox transform(final Matrix4f mat, final AABBox out) {
+ final Vec3f tmp = new Vec3f();
+ out.reset();
+ out.resize( mat.mulVec3f(low, tmp) );
+ out.resize( mat.mulVec3f(high, tmp) );
+ out.computeCenter();
+ return out;
}
- public AABBox transform(final AABBox result, final Matrix4f mat,
- final Vec3f vec3Tmp) {
- result.reset();
- result.resize( mat.mulVec3f(low, vec3Tmp) );
-
- result.resize( mat.mulVec3f(high, vec3Tmp) );
-
- result.computeCenter();
- return result;
+ /**
+ * Transform this box using the {@link PMVMatrix#getMvMat() modelview} of the given {@link PMVMatrix} into {@code out}
+ * @param pmv transformation {@link PMVMatrix}
+ * @param out the resulting {@link AABBox}
+ * @return the resulting {@link AABBox} for chaining
+ */
+ public AABBox transformMv(final PMVMatrix pmv, final AABBox out) {
+ final Vec3f tmp = new Vec3f();
+ out.reset();
+ out.resize( pmv.mulMvMatVec3f(low, tmp) );
+ out.resize( pmv.mulMvMatVec3f(high, tmp) );
+ out.computeCenter();
+ return out;
}
/**
@@ -771,56 +765,51 @@ public class AABBox {
* | |
* .y() ------ [3]
* </pre>
- * @param mat4PMv P x Mv matrix
- * @param view
+ * @param mat4PMv [projection] x [modelview] matrix, i.e. P x Mv
+ * @param viewport viewport rectangle
* @param useCenterZ
* @param vec3Tmp0 3 component vector for temp storage
* @param vec4Tmp1 4 component vector for temp storage
* @param vec4Tmp2 4 component vector for temp storage
* @return
*/
- public AABBox mapToWindow(final AABBox result, final float[/*16*/] mat4PMv, final int[] view, final boolean useCenterZ,
- final float[] vec3Tmp0, final float[] vec4Tmp1, final float[] vec4Tmp2) {
+ public AABBox mapToWindow(final AABBox result, final Matrix4f mat4PMv, final Recti viewport, final boolean useCenterZ) {
+ final Vec3f tmp = new Vec3f();
+ final Vec3f winPos = new Vec3f();
{
- // System.err.printf("AABBox.mapToWindow.0: view[%d, %d, %d, %d], this %s%n", view.x(), view.y(), view.z(), view[3], toString());
final float objZ = useCenterZ ? center.z() : getMinZ();
- FloatUtil.mapObjToWin(getMinX(), getMinY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- // System.err.printf("AABBox.mapToWindow.p1: %f, %f, %f -> %f, %f, %f%n", getMinX(), getMinY(), objZ, vec3Tmp0.x(), vec3Tmp0.y(), vec3Tmp0.z());
- // System.err.println("AABBox.mapToWindow.p1:");
- // System.err.println(FloatUtil.matrixToString(null, " mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
-
result.reset();
- result.resize(vec3Tmp0);
- FloatUtil.mapObjToWin(getMinX(), getMaxY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- // System.err.printf("AABBox.mapToWindow.p2: %f, %f, %f -> %f, %f, %f%n", getMinX(), getMaxY(), objZ, vec3Tmp0.x(), vec3Tmp0.y(), vec3Tmp0.z());
- result.resize(vec3Tmp0);
+ Matrix4f.mapObjToWin(tmp.set(getMinX(), getMinY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
- FloatUtil.mapObjToWin(getMaxX(), getMinY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- // System.err.printf("AABBox.mapToWindow.p3: %f, %f, %f -> %f, %f, %f%n", getMaxX(), getMinY(), objZ, vec3Tmp0.x(), vec3Tmp0.y(), vec3Tmp0.z());
- result.resize(vec3Tmp0);
+ Matrix4f.mapObjToWin(tmp.set(getMinX(), getMaxY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
- FloatUtil.mapObjToWin(getMaxX(), getMaxY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- // System.err.printf("AABBox.mapToWindow.p4: %f, %f, %f -> %f, %f, %f%n", getMaxX(), getMaxY(), objZ, vec3Tmp0.x(), vec3Tmp0.y(), vec3Tmp0.z());
- result.resize(vec3Tmp0);
+ Matrix4f.mapObjToWin(tmp.set(getMaxX(), getMaxY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
+
+ Matrix4f.mapObjToWin(tmp.set(getMaxX(), getMinY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
}
if( !useCenterZ ) {
final float objZ = getMaxZ();
- FloatUtil.mapObjToWin(getMinX(), getMinY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- result.resize(vec3Tmp0);
- FloatUtil.mapObjToWin(getMinX(), getMaxY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- result.resize(vec3Tmp0);
+ Matrix4f.mapObjToWin(tmp.set(getMinX(), getMinY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
+
+ Matrix4f.mapObjToWin(tmp.set(getMinX(), getMaxY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
- FloatUtil.mapObjToWin(getMaxX(), getMinY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- result.resize(vec3Tmp0);
+ Matrix4f.mapObjToWin(tmp.set(getMaxX(), getMaxY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
- FloatUtil.mapObjToWin(getMaxX(), getMaxY(), objZ, mat4PMv, view, vec3Tmp0, vec4Tmp1, vec4Tmp2);
- result.resize(vec3Tmp0);
+ Matrix4f.mapObjToWin(tmp.set(getMaxX(), getMinY(), objZ), mat4PMv, viewport, winPos);
+ result.resize(winPos);
}
if( DEBUG ) {
- System.err.printf("AABBox.mapToWindow: view[%d, %d], this %s -> %s%n", view[0], view[1], toString(), result.toString());
+ System.err.printf("AABBox.mapToWindow: view[%s], this %s -> %s%n", viewport, toString(), result.toString());
}
return result;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
index 4d098cb72..f72154827 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
@@ -37,7 +37,7 @@ import com.jogamp.opengl.math.geom.Frustum.FovDesc;
/**
* Providing frustum {@link #getPlanes() planes} derived by different inputs
- * ({@link #updateByPMV(float[], int) P*MV}, ..) used to classify objects
+ * ({@link #updateFrustumPlanes(float[], int) P*MV}, ..) used to classify objects
* <ul>
* <li> {@link #classifyPoint(float[]) point} </li>
* <li> {@link #classifySphere(float[], float) sphere} </li>
@@ -120,7 +120,7 @@ public class Frustum {
* Use one of the <code>update(..)</code> methods to set the {@link #getPlanes() planes}.
* </p>
* @see #updateByPlanes(Plane[])
- * @see #updateByPMV(float[], int)
+ * @see #updateFrustumPlanes(float[], int)
*/
public Frustum() {
for (int i = 0; i < 6; ++i) {
@@ -162,11 +162,6 @@ public class Frustum {
}
/** Return distance of plane to given point, see {@link #distanceTo(float, float, float)}. */
- public final float distanceTo(final float[] p) {
- return n.x() * p[0] + n.y() * p[1] + n.z() * p[2] + d;
- }
-
- /** Return distance of plane to given point, see {@link #distanceTo(float, float, float)}. */
public final float distanceTo(final Vec3f p) {
return n.x() * p.x() + n.y() * p.y() + n.z() * p.z() + d;
}
@@ -254,87 +249,14 @@ public class Frustum {
/**
* Calculate the frustum planes in world coordinates
- * using the passed float[16] as premultiplied P*MV (column major order).
+ * using the passed premultiplied P*MV (column major order) matrix.
* <p>
* Frustum plane's normals will point to the inside of the viewing frustum,
* as required by this class.
* </p>
*/
- public void updateByPMV(final float[] pmv, final int pmv_off) {
- // Left: a = m41 + m11, b = m42 + m12, c = m43 + m13, d = m44 + m14 - [1..4] column-major
- // Left: a = m30 + m00, b = m31 + m01, c = m32 + m02, d = m33 + m03 - [0..3] column-major
- {
- final Plane p = planes[LEFT];
- final Vec3f p_n = p.n;
- p_n.set( pmv[ pmv_off + 3 + 0 * 4 ] + pmv[ pmv_off + 0 + 0 * 4 ],
- pmv[ pmv_off + 3 + 1 * 4 ] + pmv[ pmv_off + 0 + 1 * 4 ],
- pmv[ pmv_off + 3 + 2 * 4 ] + pmv[ pmv_off + 0 + 2 * 4 ] );
- p.d = pmv[ pmv_off + 3 + 3 * 4 ] + pmv[ pmv_off + 0 + 3 * 4 ];
- }
-
- // Right: a = m41 - m11, b = m42 - m12, c = m43 - m13, d = m44 - m14 - [1..4] column-major
- // Right: a = m30 - m00, b = m31 - m01, c = m32 - m02, d = m33 - m03 - [0..3] column-major
- {
- final Plane p = planes[RIGHT];
- final Vec3f p_n = p.n;
- p_n.set( pmv[ pmv_off + 3 + 0 * 4 ] - pmv[ pmv_off + 0 + 0 * 4 ],
- pmv[ pmv_off + 3 + 1 * 4 ] - pmv[ pmv_off + 0 + 1 * 4 ],
- pmv[ pmv_off + 3 + 2 * 4 ] - pmv[ pmv_off + 0 + 2 * 4 ] );
- p.d = pmv[ pmv_off + 3 + 3 * 4 ] - pmv[ pmv_off + 0 + 3 * 4 ];
- }
-
- // Bottom: a = m41 + m21, b = m42 + m22, c = m43 + m23, d = m44 + m24 - [1..4] column-major
- // Bottom: a = m30 + m10, b = m31 + m11, c = m32 + m12, d = m33 + m13 - [0..3] column-major
- {
- final Plane p = planes[BOTTOM];
- final Vec3f p_n = p.n;
- p_n.set( pmv[ pmv_off + 3 + 0 * 4 ] + pmv[ pmv_off + 1 + 0 * 4 ],
- pmv[ pmv_off + 3 + 1 * 4 ] + pmv[ pmv_off + 1 + 1 * 4 ],
- pmv[ pmv_off + 3 + 2 * 4 ] + pmv[ pmv_off + 1 + 2 * 4 ] );
- p.d = pmv[ pmv_off + 3 + 3 * 4 ] + pmv[ pmv_off + 1 + 3 * 4 ];
- }
-
- // Top: a = m41 - m21, b = m42 - m22, c = m43 - m23, d = m44 - m24 - [1..4] column-major
- // Top: a = m30 - m10, b = m31 - m11, c = m32 - m12, d = m33 - m13 - [0..3] column-major
- {
- final Plane p = planes[TOP];
- final Vec3f p_n = p.n;
- p_n.set( pmv[ pmv_off + 3 + 0 * 4 ] - pmv[ pmv_off + 1 + 0 * 4 ],
- pmv[ pmv_off + 3 + 1 * 4 ] - pmv[ pmv_off + 1 + 1 * 4 ],
- pmv[ pmv_off + 3 + 2 * 4 ] - pmv[ pmv_off + 1 + 2 * 4 ] );
- p.d = pmv[ pmv_off + 3 + 3 * 4 ] - pmv[ pmv_off + 1 + 3 * 4 ];
- }
-
- // Near: a = m41 + m31, b = m42 + m32, c = m43 + m33, d = m44 + m34 - [1..4] column-major
- // Near: a = m30 + m20, b = m31 + m21, c = m32 + m22, d = m33 + m23 - [0..3] column-major
- {
- final Plane p = planes[NEAR];
- final Vec3f p_n = p.n;
- p_n.set( pmv[ pmv_off + 3 + 0 * 4 ] + pmv[ pmv_off + 2 + 0 * 4 ],
- pmv[ pmv_off + 3 + 1 * 4 ] + pmv[ pmv_off + 2 + 1 * 4 ],
- pmv[ pmv_off + 3 + 2 * 4 ] + pmv[ pmv_off + 2 + 2 * 4 ] );
- p.d = pmv[ pmv_off + 3 + 3 * 4 ] + pmv[ pmv_off + 2 + 3 * 4 ];
- }
-
- // Far: a = m41 - m31, b = m42 - m32, c = m43 - m33, d = m44 - m34 - [1..4] column-major
- // Far: a = m30 - m20, b = m31 - m21, c = m32 + m22, d = m33 + m23 - [0..3] column-major
- {
- final Plane p = planes[FAR];
- final Vec3f p_n = p.n;
- p_n.set( pmv[ pmv_off + 3 + 0 * 4 ] - pmv[ pmv_off + 2 + 0 * 4 ],
- pmv[ pmv_off + 3 + 1 * 4 ] - pmv[ pmv_off + 2 + 1 * 4 ],
- pmv[ pmv_off + 3 + 2 * 4 ] - pmv[ pmv_off + 2 + 2 * 4 ] );
- p.d = pmv[ pmv_off + 3 + 3 * 4 ] - pmv[ pmv_off + 2 + 3 * 4 ];
- }
-
- // Normalize all planes
- for (int i = 0; i < 6; ++i) {
- final Plane p = planes[i];
- final Vec3f p_n = p.n;
- final float invLen = 1f / p_n.length();
- p_n.scale(invLen);
- p.d *= invLen;
- }
+ public void updateFrustumPlanes(final Matrix4f pmv) {
+ pmv.updateFrustumPlanes(this);
}
private static final boolean isOutsideImpl(final Plane p, final AABBox box) {
@@ -380,7 +302,7 @@ public class Frustum {
* @param p the point
* @return {@link Location} of point related to frustum planes
*/
- public final Location classifyPoint(final float[] p) {
+ public final Location classifyPoint(final Vec3f p) {
Location res = Location.INSIDE;
for (int i = 0; i < 6; ++i) {
@@ -400,7 +322,7 @@ public class Frustum {
* @param p the point
* @return true if outside of the frustum, otherwise inside or on a plane
*/
- public final boolean isPointOutside(final float[] p) {
+ public final boolean isPointOutside(final Vec3f p) {
return Location.OUTSIDE == classifyPoint(p);
}
@@ -411,7 +333,7 @@ public class Frustum {
* @param radius radius of the sphere
* @return {@link Location} of point related to frustum planes
*/
- public final Location classifySphere(final float[] p, final float radius) {
+ public final Location classifySphere(final Vec3f p, final float radius) {
Location res = Location.INSIDE; // fully inside
for (int i = 0; i < 6; ++i) {
@@ -434,7 +356,7 @@ public class Frustum {
* @param radius radius of the sphere
* @return true if outside of the frustum, otherwise inside or intersecting
*/
- public final boolean isSphereOutside(final float[] p, final float radius) {
+ public final boolean isSphereOutside(final Vec3f p, final float radius) {
return Location.OUTSIDE == classifySphere(p, radius);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
index 1aa305c2e..0d9617fb4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
@@ -1,65 +1,68 @@
-/*
- * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
+/**
+ * Copyright 2009-2023 JogAmp Community. All rights reserved.
*
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
*
- * - Redistribution 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.
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
*
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * 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 "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ * 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.util;
+import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.GLUniformData;
import jogamp.common.os.PlatformPropsImpl;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.util.FloatStack;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Matrix4f;
import com.jogamp.opengl.math.Quaternion;
import com.jogamp.opengl.math.Ray;
+import com.jogamp.opengl.math.Recti;
+import com.jogamp.opengl.math.Vec3f;
+import com.jogamp.opengl.math.Vec4f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.math.geom.Frustum;
/**
* PMVMatrix implements a subset of the fixed function pipeline
- * regarding the projection (P), modelview (Mv) matrix operation
+ * regarding the projection (P), modelview (Mv) and texture (T) matrix operations,
* which is specified in {@link GLMatrixFunc}.
* <p>
- * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and
- * {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}.
- * {@link Frustum} is also provided by {@link #glGetFrustum()}.
+ * This is the second implementation of {@code PMVMatrix} using
+ * direct {@link Matrix4f}, {@link Vec4f} and {@link Vec3f} math operations instead of {@code float[]}
+ * via {@link com.jogamp.opengl.math.FloatUtil FloatUtil}.
+ * </p>
+ * <p>
+ * PMVMatrix provides the {@link #getMviMat() inverse modelview matrix (Mvi)} and
+ * {@link #getMvitMat() inverse transposed modelview matrix (Mvit)}.
+ * {@link Frustum} is also provided by {@link #getFrustum()}.
+ *
* To keep these derived values synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)}
* in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}),
* users have to call {@link #update()} before using Mvi and Mvit.
@@ -67,7 +70,7 @@ import com.jogamp.opengl.math.geom.Frustum;
* <p>
* All matrices are provided in column-major order,
* as specified in the OpenGL fixed function pipeline, i.e. compatibility profile.
- * See {@link FloatUtil}.
+ * See {@link Matrix4f}.
* </p>
* <p>
* PMVMatrix can supplement {@link GL2ES2} applications w/ the
@@ -75,6 +78,23 @@ import com.jogamp.opengl.math.geom.Frustum;
* </p>
* <a name="storageDetails"><h5>Matrix storage details</h5></a>
* <p>
+ * The {@link SyncBuffer} abstraction is provided, e.g. {@link #getSyncPMvMviMat()},
+ * to synchronize the respective {@link Matrix4f matrices} with the {@code float[]} backing store.
+ * The latter is represents the data to {@link GLUniformData} via its {@link FloatBuffer}s, see {@link SyncBuffer#getBuffer()},
+ * and is pushed to the GPU eventually.
+ *
+ * {@link SyncBuffer}'s {@link SyncAction} is called by {@link GLUniformData#getBuffer()},
+ * i.e. before the data is pushed to the GPU.
+ *
+ * The provided {@link SyncAction} ensures that the {@link Matrix4f matrices data}
+ * gets copied into the {@code float[]} backing store.
+ *
+ * PMVMatrix provides two specializations of {@link SyncBuffer}, {@link SyncMatrix} for single {@link Matrix4f} mappings
+ * and {@link SyncMatrices4f} for multiple {@link Matrix4f} mappings.
+ *
+ * They can be feed directly to instantiate a {@link GLUniformData} object via e.g. {@link GLUniformData#GLUniformData(String, int, int, SyncBuffer)}.
+ * </p>
+ * <p>
* All matrices are backed up by a common primitive float-array for performance considerations
* and are a {@link Buffers#slice2Float(float[], int, int) sliced} representation of it.
* </p>
@@ -89,20 +109,20 @@ import com.jogamp.opengl.math.geom.Frustum;
*/
public final class PMVMatrix implements GLMatrixFunc {
- /** Bit value stating a modified {@link #glGetPMatrixf() projection matrix (P)}, since last {@link #update()} call. */
+ /** Bit value stating a modified {@link #getPMat() projection matrix (P)}, since last {@link #update()} call. */
public static final int MODIFIED_PROJECTION = 1 << 0;
- /** Bit value stating a modified {@link #glGetMvMatrixf() modelview matrix (Mv)}, since last {@link #update()} call. */
+ /** Bit value stating a modified {@link #getMvMat() modelview matrix (Mv)}, since last {@link #update()} call. */
public static final int MODIFIED_MODELVIEW = 1 << 1;
- /** Bit value stating a modified {@link #glGetTMatrixf() texture matrix (T)}, since last {@link #update()} call. */
+ /** Bit value stating a modified {@link #getTMat() texture matrix (T)}, since last {@link #update()} call. */
public static final int MODIFIED_TEXTURE = 1 << 2;
/** Bit value stating all is modified */
public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ;
- /** Bit value stating a dirty {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)}. */
+ /** Bit value stating a dirty {@link #getMviMat() inverse modelview matrix (Mvi)}. */
public static final int DIRTY_INVERSE_MODELVIEW = 1 << 0;
- /** Bit value stating a dirty {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. */
+ /** Bit value stating a dirty {@link #getMvitMat() inverse transposed modelview matrix (Mvit)}. */
public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1;
- /** Bit value stating a dirty {@link #glGetFrustum() frustum}. */
+ /** Bit value stating a dirty {@link #getFrustum() frustum}. */
public static final int DIRTY_FRUSTUM = 1 << 2;
/** Bit value stating all is dirty */
public static final int DIRTY_ALL = DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM;
@@ -171,29 +191,6 @@ public final class PMVMatrix implements GLMatrixFunc {
}
/**
- * @param sb optional passed StringBuilder instance to be used
- * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter}
- * @param a 4x4 matrix in column major order (OpenGL)
- * @return matrix string representation
- */
- @SuppressWarnings("deprecation")
- public static StringBuilder matrixToString(final StringBuilder sb, final String f, final FloatBuffer a) {
- return FloatUtil.matrixToString(sb, null, f, a, 0, 4, 4, false);
- }
-
- /**
- * @param sb optional passed StringBuilder instance to be used
- * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter}
- * @param a 4x4 matrix in column major order (OpenGL)
- * @param b 4x4 matrix in column major order (OpenGL)
- * @return side by side representation
- */
- @SuppressWarnings("deprecation")
- public static StringBuilder matrixToString(final StringBuilder sb, final String f, final FloatBuffer a, final FloatBuffer b) {
- return FloatUtil.matrixToString(sb, null, f, a, 0, b, 0, 4, 4, false);
- }
-
- /**
* Creates an instance of PMVMatrix.
* <p>
* Implementation uses non-direct non-NIO Buffers with guaranteed backing array,
@@ -207,31 +204,43 @@ public final class PMVMatrix implements GLMatrixFunc {
// Mv ModelView
// Mvi Modelview-Inverse
// Mvit Modelview-Inverse-Transpose
- matrixArray = new float[5*16];
-
- // mP_offset = 0*16;
- // mMv_offset = 1*16;
- // mTex_offset = 4*16;
-
- matrixPMvMvit = Buffers.slice2Float(matrixArray, 0*16, 4*16); // P + Mv + Mvi + Mvit
- matrixPMvMvi = Buffers.slice2Float(matrixArray, 0*16, 3*16); // P + Mv + Mvi
- matrixPMv = Buffers.slice2Float(matrixArray, 0*16, 2*16); // P + Mv
- matrixP = Buffers.slice2Float(matrixArray, 0*16, 1*16); // P
- matrixMv = Buffers.slice2Float(matrixArray, 1*16, 1*16); // Mv
- matrixMvi = Buffers.slice2Float(matrixArray, 2*16, 1*16); // Mvi
- matrixMvit = Buffers.slice2Float(matrixArray, 3*16, 1*16); // Mvit
- matrixTex = Buffers.slice2Float(matrixArray, 4*16, 1*16); // T
-
- mat4Tmp1 = new float[16];
- mat4Tmp2 = new float[16];
- mat4Tmp3 = new float[16];
- matrixTxSx = new float[16];
- FloatUtil.makeIdentity(matrixTxSx);
-
- // Start w/ zero size to save memory
- matrixTStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2)
- matrixPStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2)
- matrixMvStack= new FloatStack( 0, 16*16); // growSize: half GL-min size (32)
+
+ // actual underlying Matrix4f data
+ matP = new Matrix4f();
+ matMv = new Matrix4f();
+ matMvi = new Matrix4f();
+ matMvit = new Matrix4f();
+ matTex = new Matrix4f();
+
+ // float back buffer for GPU, Matrix4f -> matrixStore via SyncedBuffer
+ matrixStore = new float[5*16];
+
+ // FloatBuffer for single Matrix4f back-buffer
+ matrixP = Buffers.slice2Float(matrixStore, mP_offset, 1*16); // P
+ matrixMv = Buffers.slice2Float(matrixStore, mMv_offset, 1*16); // Mv
+ matrixMvi = Buffers.slice2Float(matrixStore, mMvi_offset, 1*16); // Mvi
+ matrixMvit = Buffers.slice2Float(matrixStore, mMvit_offset, 1*16); // Mvit
+ matrixTex = Buffers.slice2Float(matrixStore, mTex_offset, 1*16); // T
+
+ // FloatBuffer for aggregated multiple Matrix4f back-buffer
+ matrixPMvMvit = Buffers.slice2Float(matrixStore, mP_offset, 4*16); // P + Mv + Mvi + Mvit
+ matrixPMvMvi = Buffers.slice2Float(matrixStore, mP_offset, 3*16); // P + Mv + Mvi
+ matrixPMv = Buffers.slice2Float(matrixStore, mP_offset, 2*16); // P + Mv
+
+ matPSync = new SyncBuffer0(matP, matrixP); // mP_offset
+ matMvSync = new SyncBuffer1(matMv, matrixMv, mMv_offset);
+ matMviSync = new SyncBuffer1(matMvi, matrixMvi, mMvi_offset);
+ matMvitSync = new SyncBuffer1(matMvit, matrixMvit, mMvit_offset);
+ matTexSync = new SyncBuffer1(matTex, matrixTex, mTex_offset);
+
+ matPMvMvitSync = new SyncBufferN(new Matrix4f[] { matP, matMv, matMvi, matMvit }, matrixPMvMvit, mP_offset);
+ matPMvMviSync = new SyncBufferN(new Matrix4f[] { matP, matMv, matMvi }, matrixPMvMvi, mP_offset);
+ matPMvSync = new SyncBufferN(new Matrix4f[] { matP, matMv }, matrixPMv, mP_offset);
+
+ mat4Tmp1 = new Matrix4f();
+ mat4Tmp2 = new Matrix4f();
+ vec3Tmp1 = new Vec3f();
+ vec4Tmp1 = new Vec4f();
reset();
@@ -246,9 +255,9 @@ public final class PMVMatrix implements GLMatrixFunc {
* Leaves {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW} the active matrix mode.
*/
public final void reset() {
- FloatUtil.makeIdentity(matrixArray, mMv_offset);
- FloatUtil.makeIdentity(matrixArray, mP_offset);
- FloatUtil.makeIdentity(matrixArray, mTex_offset);
+ matP.loadIdentity();
+ matMv.loadIdentity();
+ matTex.loadIdentity();
modifiedBits = MODIFIED_ALL;
dirtyBits = DIRTY_ALL;
@@ -261,14 +270,27 @@ public final class PMVMatrix implements GLMatrixFunc {
return matrixMode;
}
+ //
+ // Matrix4f access as well as their SyncedBuffer counterpart SyncedMatrix and SyncedMatrices
+ //
/**
* Returns the {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T).
* <p>
* See <a href="#storageDetails"> matrix storage details</a>.
* </p>
*/
- public final FloatBuffer glGetTMatrixf() {
- return matrixTex;
+ public final Matrix4f getTMat() {
+ return matTex;
+ }
+
+ /**
+ * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T).
+ * <p>
+ * See <a href="#storageDetails"> matrix storage details</a>.
+ * </p>
+ */
+ public final SyncMatrix4f getSyncTMat() {
+ return matTexSync;
}
/**
@@ -277,8 +299,18 @@ public final class PMVMatrix implements GLMatrixFunc {
* See <a href="#storageDetails"> matrix storage details</a>.
* </p>
*/
- public final FloatBuffer glGetPMatrixf() {
- return matrixP;
+ public final Matrix4f getPMat() {
+ return matP;
+ }
+
+ /**
+ * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P).
+ * <p>
+ * See <a href="#storageDetails"> matrix storage details</a>.
+ * </p>
+ */
+ public final SyncMatrix4f getSyncPMat() {
+ return matPSync;
}
/**
@@ -287,8 +319,18 @@ public final class PMVMatrix implements GLMatrixFunc {
* See <a href="#storageDetails"> matrix storage details</a>.
* </p>
*/
- public final FloatBuffer glGetMvMatrixf() {
- return matrixMv;
+ public final Matrix4f getMvMat() {
+ return matMv;
+ }
+
+ /**
+ * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv).
+ * <p>
+ * See <a href="#storageDetails"> matrix storage details</a>.
+ * </p>
+ */
+ public final SyncMatrix4f getSyncMvMat() {
+ return matMvSync;
}
/**
@@ -302,10 +344,27 @@ public final class PMVMatrix implements GLMatrixFunc {
* @see #update()
* @see #clearAllUpdateRequests()
*/
- public final FloatBuffer glGetMviMatrixf() {
+ public final Matrix4f getMviMat() {
+ requestMask |= DIRTY_INVERSE_MODELVIEW ;
+ updateImpl(false);
+ return matMvi;
+ }
+
+ /**
+ * Returns the {@link SyncMatrix} of inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi).
+ * <p>
+ * Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits.
+ * </p>
+ * <p>
+ * See {@link #update()} and <a href="#storageDetails"> matrix storage details</a>.
+ * </p>
+ * @see #update()
+ * @see #clearAllUpdateRequests()
+ */
+ public final SyncMatrix4f getSyncMviMat() {
requestMask |= DIRTY_INVERSE_MODELVIEW ;
updateImpl(false);
- return matrixMvi;
+ return matMviSync;
}
/**
@@ -319,24 +378,41 @@ public final class PMVMatrix implements GLMatrixFunc {
* @see #update()
* @see #clearAllUpdateRequests()
*/
- public final FloatBuffer glGetMvitMatrixf() {
+ public final Matrix4f getMvitMat() {
requestMask |= DIRTY_INVERSE_TRANSPOSED_MODELVIEW ;
updateImpl(false);
- return matrixMvit;
+ return matMvit;
}
/**
- * Returns 2 matrices within one FloatBuffer: {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv}.
+ * Returns the {@link SyncMatrix} of inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit).
+ * <p>
+ * Method enables the Mvit matrix update, and performs it's update w/o clearing the modified bits.
+ * </p>
+ * <p>
+ * See {@link #update()} and <a href="#storageDetails"> matrix storage details</a>.
+ * </p>
+ * @see #update()
+ * @see #clearAllUpdateRequests()
+ */
+ public final SyncMatrix4f getSyncMvitMat() {
+ requestMask |= DIRTY_INVERSE_TRANSPOSED_MODELVIEW ;
+ updateImpl(false);
+ return matMvitSync;
+ }
+
+ /**
+ * Returns {@link SyncMatrices4f} of 2 matrices within one FloatBuffer: {@link #getPMat() P} and {@link #getMvMat() Mv}.
* <p>
* See <a href="#storageDetails"> matrix storage details</a>.
* </p>
*/
- public final FloatBuffer glGetPMvMatrixf() {
- return matrixPMv;
+ public final SyncMatrices4f getSyncPMvMat() {
+ return matPMvSync;
}
/**
- * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}.
+ * Returns {@link SyncMatrices4f} of 3 matrices within one FloatBuffer: {@link #getPMat() P}, {@link #getMvMat() Mv} and {@link #getMviMat() Mvi}.
* <p>
* Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits.
* </p>
@@ -346,14 +422,14 @@ public final class PMVMatrix implements GLMatrixFunc {
* @see #update()
* @see #clearAllUpdateRequests()
*/
- public final FloatBuffer glGetPMvMviMatrixf() {
+ public final SyncMatrices4f getSyncPMvMviMat() {
requestMask |= DIRTY_INVERSE_MODELVIEW ;
updateImpl(false);
- return matrixPMvMvi;
+ return matPMvMviSync;
}
/**
- * Returns 4 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv}, {@link #glGetMviMatrixf() Mvi} and {@link #glGetMvitMatrixf() Mvit}.
+ * Returns {@link SyncMatrices4f} of 4 matrices within one FloatBuffer: {@link #getPMat() P}, {@link #getMvMat() Mv}, {@link #getMviMat() Mvi} and {@link #getMvitMat() Mvit}.
* <p>
* Method enables the Mvi and Mvit matrix update, and performs it's update w/o clearing the modified bits.
* </p>
@@ -363,14 +439,14 @@ public final class PMVMatrix implements GLMatrixFunc {
* @see #update()
* @see #clearAllUpdateRequests()
*/
- public final FloatBuffer glGetPMvMvitMatrixf() {
+ public final SyncMatrices4f getSyncPMvMvitMat() {
requestMask |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ;
updateImpl(false);
- return matrixPMvMvit;
+ return matPMvMvitSync;
}
/** Returns the frustum, derived from projection * modelview */
- public final Frustum glGetFrustum() {
+ public final Frustum getFrustum() {
requestMask |= DIRTY_FRUSTUM;
updateImpl(false);
return frustum;
@@ -379,8 +455,8 @@ public final class PMVMatrix implements GLMatrixFunc {
/**
* @return the matrix of the current matrix-mode
*/
- public final FloatBuffer glGetMatrixf() {
- return glGetMatrixf(matrixMode);
+ public final Matrix4f getCurrentMat() {
+ return getMat(matrixMode);
}
/**
@@ -390,90 +466,93 @@ public final class PMVMatrix implements GLMatrixFunc {
* {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}
* @return the named matrix, not a copy!
*/
- public final FloatBuffer glGetMatrixf(final int matrixName) {
+ public final Matrix4f getMat(final int matrixName) {
switch(matrixName) {
case GL_MODELVIEW_MATRIX:
case GL_MODELVIEW:
- return matrixMv;
+ return matMv;
case GL_PROJECTION_MATRIX:
case GL_PROJECTION:
- return matrixP;
+ return matP;
case GL_TEXTURE_MATRIX:
case GL.GL_TEXTURE:
- return matrixTex;
+ return matTex;
default:
throw new GLException("unsupported matrixName: "+matrixName);
}
}
+ //
+ // Basic Matrix4f, Vec3f and Vec4f operations similar to GLMatrixFunc
+ //
+
/**
- * Multiplies the {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv} matrix, i.e.
+ * Multiplies the {@link #getPMat() P} and {@link #getMvMat() Mv} matrix, i.e.
* <pre>
- * mat4PMv = P x Mv
+ * result = P x Mv
* </pre>
- * @param mat4PMv 4x4 matrix storage for result
- * @param mat4PMv_offset
- * @return given matrix for chaining
+ * @param result 4x4 matrix storage for result
+ * @return given result matrix for chaining
*/
- public final float[] multPMvMatrixf(final float[/*16*/] mat4PMv, final int mat4PMv_offset) {
- FloatUtil.multMatrix(matrixArray, mP_offset, matrixArray, mMv_offset, mat4PMv, mat4PMv_offset);
- return mat4PMv;
+ public final Matrix4f mulPMvMat(final Matrix4f result) {
+ return result.mul(matP, matMv);
}
/**
- * Multiplies the {@link #glGetMvMatrixf() Mv} and {@link #glGetPMatrixf() P} matrix, i.e.
+ * Multiplies the {@link #getMvMat() Mv} and {@link #getPMat() P} matrix, i.e.
* <pre>
- * mat4MvP = Mv x P
+ * result = Mv x P
* </pre>
- * @param mat4MvP 4x4 matrix storage for result
- * @param mat4MvP_offset
- * @return given matrix for chaining
+ * @param result 4x4 matrix storage for result
+ * @return given result matrix for chaining
*/
- public final float[] multMvPMatrixf(final float[/*16*/] mat4MvP, final int mat4MvP_offset) {
- FloatUtil.multMatrix(matrixArray, mMv_offset, matrixArray, mP_offset, mat4MvP, mat4MvP_offset);
- return mat4MvP;
+ public final Matrix4f mulMvPMat(final Matrix4f result) {
+ return result.mul(matMv, matP);
}
/**
* v_out = Mv * v_in
- * @param v_in float[4] input vector
- * @param v_out float[4] output vector
+ * @param v_in input vector
+ * @param v_out output vector
+ * @return given result vector for chaining
*/
- public final void multMvMatVec4f(final float[/*4*/] v_in, final float[/*4*/] v_out) {
- FloatUtil.multMatrixVec(matrixArray, mMv_offset, v_in, v_out);
+ public final Vec4f mulMvMatVec4f(final Vec4f v_in, final Vec4f v_out) {
+ return matMv.mulVec4f(v_in, v_out);
}
/**
* v_out = Mv * v_in
*
- * Affine 3f-vector transformation by 4x4 matrix, see {@link FloatUtil#multMatrixVec3(float[], int, float[], float[])}.
+ * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}.
*
- * @param v_in float[3] input vector
- * @param v_out float[3] output vector
+ * @param v_in input vector
+ * @param v_out output vector
+ * @return given result vector for chaining
*/
- public final void multMvMatVec3f(final float[/*3*/] v_in, final float[/*3*/] v_out) {
- FloatUtil.multMatrixVec3(matrixArray, mMv_offset, v_in, v_out);
+ public final Vec3f mulMvMatVec3f(final Vec3f v_in, final Vec3f v_out) {
+ return matMv.mulVec3f(v_in, v_out);
}
/**
* v_out = P * v_in
- * @param v_in float[4] input vector
- * @param v_out float[4] output vector
+ * @param v_in input vector
+ * @param v_out output vector
+ * @return given result vector for chaining
*/
- public final void multPMatVec4f(final float[/*4*/] v_in, final float[/*4*/] v_out) {
- FloatUtil.multMatrixVec(matrixArray, v_in, v_out); // mP_offset := 0
+ public final Vec4f mulPMatVec4f(final Vec4f v_in, final Vec4f v_out) {
+ return matP.mulVec4f(v_in, v_out);
}
/**
* v_out = P * v_in
*
- * Affine 3f-vector transformation by 4x4 matrix, see {@link FloatUtil#multMatrixVec3(float[], int, float[], float[])}.
+ * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}.
*
* @param v_in float[3] input vector
* @param v_out float[3] output vector
*/
- public final void multPMatVec3f(final float[/*3*/] v_in, final float[/*3*/] v_out) {
- FloatUtil.multMatrixVec3(matrixArray, v_in, v_out); // mP_offset := 0
+ public final Vec3f mulPMatVec3f(final Vec3f v_in, final Vec3f v_out) {
+ return matP.mulVec3f(v_in, v_out);
}
/**
@@ -481,22 +560,20 @@ public final class PMVMatrix implements GLMatrixFunc {
* @param v_in float[4] input vector
* @param v_out float[4] output vector
*/
- public final void multPMvMatVec4f(final float[/*4*/] v_in, final float[/*4*/] v_out) {
- FloatUtil.multMatrixVec(matrixArray, mMv_offset, v_in, mat4Tmp1);
- FloatUtil.multMatrixVec(matrixArray, mat4Tmp1, v_out); // mP_offset := 0
+ public final Vec4f mulPMvMatVec4f(final Vec4f v_in, final Vec4f v_out) {
+ return matP.mulVec4f( matMv.mulVec4f( v_in, vec4Tmp1 ), v_out );
}
/**
* v_out = P * Mv * v_in
*
- * Affine 3f-vector transformation by 4x4 matrix, see {@link FloatUtil#multMatrixVec3(float[], int, float[], float[])}.
+ * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}.
*
* @param v_in float[3] input vector
* @param v_out float[3] output vector
*/
- public final void multPMvMatVec3f(final float[/*3*/] v_in, final float[/*3*/] v_out) {
- FloatUtil.multMatrixVec3(matrixArray, mMv_offset, v_in, mat4Tmp1);
- FloatUtil.multMatrixVec3(matrixArray, mat4Tmp1, v_out); // mP_offset := 0
+ public final Vec3f mulPMvMatVec3f(final Vec3f v_in, final Vec3f v_out) {
+ return matP.mulVec3f( matMv.mulVec3f( v_in, vec3Tmp1 ), v_out );
}
//
@@ -522,9 +599,7 @@ public final class PMVMatrix implements GLMatrixFunc {
if(matrixGetName==GL_MATRIX_MODE) {
params.put(matrixMode);
} else {
- final FloatBuffer matrix = glGetMatrixf(matrixGetName);
- params.put(matrix); // matrix -> params
- matrix.reset();
+ getMat(matrixGetName).get(params); // matrix -> params
}
params.position(pos);
}
@@ -534,9 +609,7 @@ public final class PMVMatrix implements GLMatrixFunc {
if(matrixGetName==GL_MATRIX_MODE) {
params[params_offset]=matrixMode;
} else {
- final FloatBuffer matrix = glGetMatrixf(matrixGetName);
- matrix.get(params, params_offset, 16); // matrix -> params
- matrix.reset();
+ getMat(matrixGetName).get(params, params_offset); // matrix -> params
}
}
@@ -563,18 +636,15 @@ public final class PMVMatrix implements GLMatrixFunc {
@Override
public final void glLoadMatrixf(final float[] values, final int offset) {
if(matrixMode==GL_MODELVIEW) {
- matrixMv.put(values, offset, 16);
- matrixMv.reset();
+ matMv.load(values, offset);
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- matrixP.put(values, offset, 16);
- matrixP.reset();
+ matP.load(values, offset);
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixTex.put(values, offset, 16);
- matrixTex.reset();
+ matTex.load(values, offset);
modifiedBits |= MODIFIED_TEXTURE;
}
}
@@ -583,18 +653,15 @@ public final class PMVMatrix implements GLMatrixFunc {
public final void glLoadMatrixf(final java.nio.FloatBuffer m) {
final int spos = m.position();
if(matrixMode==GL_MODELVIEW) {
- matrixMv.put(m);
- matrixMv.reset();
+ matMv.load(m);
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- matrixP.put(m);
- matrixP.reset();
+ matP.load(m);
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixTex.put(m);
- matrixTex.reset();
+ matTex.load(m);
modifiedBits |= MODIFIED_TEXTURE;
}
m.position(spos);
@@ -602,85 +669,80 @@ public final class PMVMatrix implements GLMatrixFunc {
/**
* Load the current matrix with the values of the given {@link Matrix4f}.
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
*/
public final void glLoadMatrixf(final Matrix4f m) {
if(matrixMode==GL_MODELVIEW) {
- m.get(matrixArray, mMv_offset);
+ matMv.load(m);
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- m.get(matrixArray, mP_offset);
+ matP.load(m);
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- m.get(matrixArray, mTex_offset);
+ matTex.load(m);
modifiedBits |= MODIFIED_TEXTURE;
}
}
/**
- * Load the current matrix with the values of the given {@link Quaternion}'s rotation {@link Quaternion#toMatrix(float[], int) matrix representation}.
+ * Load the current matrix with the values of the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}.
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
*/
public final void glLoadMatrix(final Quaternion quat) {
if(matrixMode==GL_MODELVIEW) {
- quat.toMatrix(matrixArray, mMv_offset);
- matrixMv.reset();
+ matMv.setToRotation(quat);
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- quat.toMatrix(matrixArray, mP_offset);
- matrixP.reset();
+ matP.setToRotation(quat);
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- quat.toMatrix(matrixArray, mTex_offset);
- matrixTex.reset();
+ matTex.setToRotation(quat);
modifiedBits |= MODIFIED_TEXTURE;
}
}
@Override
public final void glPopMatrix() {
- final FloatStack stack;
if(matrixMode==GL_MODELVIEW) {
- stack = matrixMvStack;
+ matMv.pop();
} else if(matrixMode==GL_PROJECTION) {
- stack = matrixPStack;
+ matP.pop();
} else if(matrixMode==GL.GL_TEXTURE) {
- stack = matrixTStack;
- } else {
- throw new InternalError("XXX: mode "+matrixMode);
+ matTex.pop();
}
- stack.position(stack.position() - 16);
- glLoadMatrixf(stack.buffer(), stack.position());
}
@Override
public final void glPushMatrix() {
if(matrixMode==GL_MODELVIEW) {
- matrixMvStack.putOnTop(matrixMv, 16);
- matrixMv.reset();
+ matMv.push();
} else if(matrixMode==GL_PROJECTION) {
- matrixPStack.putOnTop(matrixP, 16);
- matrixP.reset();
+ matP.push();
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixTStack.putOnTop(matrixTex, 16);
- matrixTex.reset();
+ matTex.push();
}
}
@Override
public final void glLoadIdentity() {
if(matrixMode==GL_MODELVIEW) {
- FloatUtil.makeIdentity(matrixArray, mMv_offset);
+ matMv.loadIdentity();
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- FloatUtil.makeIdentity(matrixArray, mP_offset);
+ matP.loadIdentity();
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- FloatUtil.makeIdentity(matrixArray, mTex_offset);
+ matTex.loadIdentity();
modifiedBits |= MODIFIED_TEXTURE;
}
}
@@ -688,76 +750,133 @@ public final class PMVMatrix implements GLMatrixFunc {
@SuppressWarnings("deprecation")
@Override
public final void glMultMatrixf(final FloatBuffer m) {
+ final int spos = m.position();
if(matrixMode==GL_MODELVIEW) {
- FloatUtil.multMatrix(matrixMv, m);
+ matMv.mul( mat4Tmp1.load( m ) );
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- FloatUtil.multMatrix(matrixP, m);
+ matP.mul( mat4Tmp1.load( m ) );
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- FloatUtil.multMatrix(matrixTex, m);
+ matTex.mul( mat4Tmp1.load( m ) );
modifiedBits |= MODIFIED_TEXTURE;
}
+ m.position(spos);
}
@Override
public final void glMultMatrixf(final float[] m, final int m_offset) {
if(matrixMode==GL_MODELVIEW) {
- FloatUtil.multMatrix(matrixArray, mMv_offset, m, m_offset);
+ matMv.mul( mat4Tmp1.load( m, m_offset ) );
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- FloatUtil.multMatrix(matrixArray, mP_offset, m, m_offset);
+ matP.mul( mat4Tmp1.load( m, m_offset ) );
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- FloatUtil.multMatrix(matrixArray, mTex_offset, m, m_offset);
+ matTex.mul( mat4Tmp1.load( m, m_offset ) );
modifiedBits |= MODIFIED_TEXTURE;
}
}
- public final void glMultMatrixf(final Matrix4f m) {
+ /**
+ * Multiply the current matrix: [c] = [c] x [m]
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
+ * @param m the right hand Matrix4f
+ * @return this instance of chaining
+ */
+ public final PMVMatrix glMultMatrixf(final Matrix4f m) {
if(matrixMode==GL_MODELVIEW) {
- new Matrix4f(matrixArray, mMv_offset).mul(m).get(matrixArray, mMv_offset);
+ matMv.mul( m );
dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_MODELVIEW;
} else if(matrixMode==GL_PROJECTION) {
- new Matrix4f(matrixArray, mP_offset).mul(m).get(matrixArray, mP_offset);
+ matP.mul( m );
dirtyBits |= DIRTY_FRUSTUM ;
modifiedBits |= MODIFIED_PROJECTION;
} else if(matrixMode==GL.GL_TEXTURE) {
- new Matrix4f(matrixArray, mTex_offset).mul(m).get(matrixArray, mTex_offset);
+ matTex.mul( m );
modifiedBits |= MODIFIED_TEXTURE;
}
+ return this;
}
@Override
public final void glTranslatef(final float x, final float y, final float z) {
- glMultMatrixf(FloatUtil.makeTranslation(matrixTxSx, false, x, y, z), 0);
+ glMultMatrixf( mat4Tmp1.setToTranslation(x, y, z) );
+ }
+
+ /**
+ * Translate the current matrix.
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
+ * @param t translation vec3
+ * @return this instance of chaining
+ */
+ public final PMVMatrix glTranslatef(final Vec3f t) {
+ return glMultMatrixf( mat4Tmp1.setToTranslation(t) );
}
@Override
public final void glScalef(final float x, final float y, final float z) {
- glMultMatrixf(FloatUtil.makeScale(matrixTxSx, false, x, y, z), 0);
+ glMultMatrixf( mat4Tmp1.setToScale(x, y, z) );
+ }
+
+ /**
+ * Scale the current matrix.
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
+ * @param s scale vec4f
+ * @return this instance of chaining
+ */
+ public final PMVMatrix glScalef(final Vec3f s) {
+ return glMultMatrixf( mat4Tmp1.setToScale(s) );
}
@Override
public final void glRotatef(final float ang_deg, final float x, final float y, final float z) {
- glMultMatrixf(FloatUtil.makeRotationAxis(mat4Tmp1, 0, FloatUtil.adegToRad(ang_deg), x, y, z, mat4Tmp2), 0);
+ glMultMatrixf( mat4Tmp1.setToRotationAxis(FloatUtil.adegToRad(ang_deg), x, y, z) );
}
/**
- * Rotate the current matrix with the given {@link Quaternion}'s rotation {@link Quaternion#toMatrix(float[], int) matrix representation}.
+ * Rotate the current matrix by the given axis and angle in radians.
+ * <p>
+ * Consider using {@link #glRotate(Quaternion)}
+ * </p>
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
+ * @param ang_rad angle in radians
+ * @param axis rotation axis
+ * @return this instance of chaining
+ * @see #glRotate(Quaternion)
*/
- public final void glRotate(final Quaternion quat) {
- glMultMatrixf(quat.toMatrix(mat4Tmp1, 0), 0);
+ public final PMVMatrix glRotatef(final float ang_rad, final Vec3f axis) {
+ return glMultMatrixf( mat4Tmp1.setToRotationAxis(ang_rad, axis) );
+ }
+
+ /**
+ * Rotate the current matrix with the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}.
+ * <p>
+ * Extension to {@link GLMatrixFunc}.
+ * </p>
+ * @param quat the {@link Quaternion}
+ * @return this instance of chaining
+ */
+ public final PMVMatrix glRotate(final Quaternion quat) {
+ return glMultMatrixf( mat4Tmp1.setToRotation(quat) );
}
@Override
public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) {
- glMultMatrixf( FloatUtil.makeOrtho(mat4Tmp1, 0, true, left, right, bottom, top, zNear, zFar), 0 );
+ glMultMatrixf( mat4Tmp1.setToOrtho(left, right, bottom, top, zNear, zFar) );
}
/**
@@ -765,11 +884,11 @@ public final class PMVMatrix implements GLMatrixFunc {
*
* @throws GLException if {@code zNear <= 0} or {@code zFar <= zNear}
* or {@code left == right}, or {@code bottom == top}.
- * @see FloatUtil#makeFrustum(float[], int, boolean, float, float, float, float, float, float)
+ * @see Matrix4f#setToFrustum(float, float, float, float, float, float)
*/
@Override
public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) throws GLException {
- glMultMatrixf( FloatUtil.makeFrustum(mat4Tmp1, 0, true, left, right, bottom, top, zNear, zFar), 0 );
+ glMultMatrixf( mat4Tmp1.setToFrustum(left, right, bottom, top, zNear, zFar) );
}
//
@@ -784,30 +903,18 @@ public final class PMVMatrix implements GLMatrixFunc {
* @param zNear
* @param zFar
* @throws GLException if {@code zNear <= 0} or {@code zFar <= zNear}
- * @see FloatUtil#makePerspective(float[], int, boolean, float, float, float, float)
+ * @see Matrix4f#setToPerspective(float, float, float, float)
*/
public final void gluPerspective(final float fovy_deg, final float aspect, final float zNear, final float zFar) throws GLException {
- glMultMatrixf( FloatUtil.makePerspective(mat4Tmp1, 0, true, fovy_deg * FloatUtil.PI / 180.0f, aspect, zNear, zFar), 0 );
+ glMultMatrixf( mat4Tmp1.setToPerspective(FloatUtil.adegToRad(fovy_deg), aspect, zNear, zFar) );
}
/**
* {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix}
* with the eye, object and orientation.
*/
- public final void gluLookAt(final float eyex, final float eyey, final float eyez,
- final float centerx, final float centery, final float centerz,
- final float upx, final float upy, final float upz) {
- mat4Tmp2[0+0] = eyex;
- mat4Tmp2[1+0] = eyey;
- mat4Tmp2[2+0] = eyez;
- mat4Tmp2[0+4] = centerx;
- mat4Tmp2[1+4] = centery;
- mat4Tmp2[2+4] = centerz;
- mat4Tmp2[0+8] = upx;
- mat4Tmp2[1+8] = upy;
- mat4Tmp2[2+8] = upz;
- glMultMatrixf(
- FloatUtil.makeLookAt(mat4Tmp1, 0, mat4Tmp2 /* eye */, 0, mat4Tmp2 /* center */, 4, mat4Tmp2 /* up */, 8, mat4Tmp3), 0);
+ public final void gluLookAt(final Vec3f eye, final Vec3f center, final Vec3f up) {
+ glMultMatrixf( mat4Tmp1.setToLookAt(eye, center, up, mat4Tmp2) );
}
/**
@@ -816,24 +923,13 @@ public final class PMVMatrix implements GLMatrixFunc {
* Traditional <code>gluProject</code> implementation.
* </p>
*
- * @param objx
- * @param objy
- * @param objz
- * @param viewport 4 component viewport vector
- * @param viewport_offset
- * @param win_pos 3 component window coordinate, the result
- * @param win_pos_offset
+ * @param objPos 3 component object coordinate
+ * @param viewport Rect4i viewport
+ * @param winPos 3 component window coordinate, the result
* @return true if successful, otherwise false (z is 1)
*/
- public final boolean gluProject(final float objx, final float objy, final float objz,
- final int[] viewport, final int viewport_offset,
- final float[] win_pos, final int win_pos_offset ) {
- return FloatUtil.mapObjToWin(objx, objy, objz,
- matrixArray, mMv_offset,
- matrixArray, mP_offset,
- viewport, viewport_offset,
- win_pos, win_pos_offset,
- mat4Tmp1, mat4Tmp2);
+ public final boolean gluProject(final Vec3f objPos, final Recti viewport, final Vec3f winPos ) {
+ return Matrix4f.mapObjToWin(objPos, matMv, matP, viewport, winPos);
}
/**
@@ -845,21 +941,17 @@ public final class PMVMatrix implements GLMatrixFunc {
* @param winx
* @param winy
* @param winz
- * @param viewport 4 component viewport vector
- * @param viewport_offset
- * @param obj_pos 3 component object coordinate, the result
- * @param obj_pos_offset
+ * @param viewport Rect4i viewport
+ * @param objPos 3 component object coordinate, the result
* @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
*/
public final boolean gluUnProject(final float winx, final float winy, final float winz,
- final int[] viewport, final int viewport_offset,
- final float[] obj_pos, final int obj_pos_offset) {
- return FloatUtil.mapWinToObj(winx, winy, winz,
- matrixArray, mMv_offset,
- matrixArray, mP_offset,
- viewport, viewport_offset,
- obj_pos, obj_pos_offset,
- mat4Tmp1, mat4Tmp2);
+ final Recti viewport, final Vec3f objPos) {
+ if( Matrix4f.mapWinToObj(winx, winy, winz, matMv, matP, viewport, objPos, mat4Tmp1) ) {
+ return true;
+ } else {
+ return false;
+ }
}
/**
@@ -872,29 +964,21 @@ public final class PMVMatrix implements GLMatrixFunc {
* @param winy
* @param winz
* @param clipw
- * @param modelMatrix 4x4 modelview matrix
- * @param modelMatrix_offset
- * @param projMatrix 4x4 projection matrix
- * @param projMatrix_offset
- * @param viewport 4 component viewport vector
- * @param viewport_offset
+ * @param viewport Rect4i viewport
* @param near
* @param far
- * @param obj_pos 4 component object coordinate, the result
- * @param obj_pos_offset
+ * @param objPos 4 component object coordinate, the result
* @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)
*/
public boolean gluUnProject4(final float winx, final float winy, final float winz, final float clipw,
- final int[] viewport, final int viewport_offset,
+ final Recti viewport,
final float near, final float far,
- final float[] obj_pos, final int obj_pos_offset ) {
- return FloatUtil.mapWinToObj4(winx, winy, winz, clipw,
- matrixArray, mMv_offset,
- matrixArray, mP_offset,
- viewport, viewport_offset,
- near, far,
- obj_pos, obj_pos_offset,
- mat4Tmp1, mat4Tmp2);
+ final Vec4f objPos) {
+ if( Matrix4f.mapWinToObj4(winx, winy, winz, clipw, matMv, matP, viewport, near, far, objPos, mat4Tmp1) ) {
+ return true;
+ } else {
+ return false;
+ }
}
/**
@@ -903,27 +987,25 @@ public final class PMVMatrix implements GLMatrixFunc {
* Traditional <code>gluPickMatrix</code> implementation.
* </p>
* <p>
- * See {@link FloatUtil#makePick(float[], int, float, float, float, float, int[], int, float[]) FloatUtil.makePick(..)} for details.
+ * See {@link Matrix4f#setToPick(float, float, float, float, Recti, int, Matrix4f) for details.
* </p>
* @param x the center x-component of a picking region in window coordinates
* @param y the center y-component of a picking region in window coordinates
* @param deltaX the width of the picking region in window coordinates.
* @param deltaY the height of the picking region in window coordinates.
- * @param viewport 4 component viewport vector
- * @param viewport_offset
+ * @param viewport Rect4i viewport vector
*/
public final void gluPickMatrix(final float x, final float y,
- final float deltaX, final float deltaY,
- final int[] viewport, final int viewport_offset) {
- if( null != FloatUtil.makePick(mat4Tmp1, 0, x, y, deltaX, deltaY, viewport, viewport_offset, mat4Tmp2) ) {
- glMultMatrixf(mat4Tmp1, 0);
+ final float deltaX, final float deltaY, final Recti viewport) {
+ if( null != mat4Tmp1.setToPick(x, y, deltaX, deltaY, viewport, mat4Tmp2) ) {
+ glMultMatrixf( mat4Tmp1 );
}
}
/**
* Map two window coordinates w/ shared X/Y and distinctive Z
* to a {@link Ray}. The resulting {@link Ray} maybe used for <i>picking</i>
- * using a {@link AABBox#getRayIntersection(Ray, float[]) bounding box}.
+ * using a {@link AABBox#getRayIntersection(Vec3f, Ray, float, boolean) bounding box}.
* <p>
* Notes for picking <i>winz0</i> and <i>winz1</i>:
* <ul>
@@ -937,17 +1019,12 @@ public final class PMVMatrix implements GLMatrixFunc {
* @param winz0
* @param winz1
* @param viewport
- * @param viewport_offset
* @param ray storage for the resulting {@link Ray}
* @return true if successful, otherwise false (failed to invert matrix, or becomes z is infinity)
*/
public final boolean gluUnProjectRay(final float winx, final float winy, final float winz0, final float winz1,
- final int[] viewport,
- final Ray ray) {
- return FloatUtil.mapWinToRay(winx, winy, winz0, winz1,
- matrixArray, mMv_offset,
- matrixArray, mP_offset, viewport,
- ray, mat4Tmp1, mat4Tmp2, mat4Tmp3);
+ final Recti viewport, final Ray ray) {
+ return Matrix4f.mapWinToRay(winx, winy, winz0, winz1, matMv, matP, viewport, ray, mat4Tmp1, mat4Tmp2);
}
public StringBuilder toString(StringBuilder sb, final String f) {
@@ -967,18 +1044,18 @@ public final class PMVMatrix implements GLMatrixFunc {
sb.append("PMVMatrix[modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT);
sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append(", Frustum ").append(frustumDirty).append("/").append(frustumReq).append("]").append(PlatformPropsImpl.NEWLINE);
sb.append(", Projection").append(PlatformPropsImpl.NEWLINE);
- matrixToString(sb, f, matrixP);
+ matP.toString(sb, null, f);
sb.append(", Modelview").append(PlatformPropsImpl.NEWLINE);
- matrixToString(sb, f, matrixMv);
+ matMv.toString(sb, null, f);
sb.append(", Texture").append(PlatformPropsImpl.NEWLINE);
- matrixToString(sb, f, matrixTex);
+ matTex.toString(sb, null, f);
if( 0 != ( requestMask & DIRTY_INVERSE_MODELVIEW ) ) {
sb.append(", Inverse Modelview").append(PlatformPropsImpl.NEWLINE);
- matrixToString(sb, f, matrixMvi);
+ matMvi.toString(sb, null, f);
}
if( 0 != ( requestMask & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) {
sb.append(", Inverse Transposed Modelview").append(PlatformPropsImpl.NEWLINE);
- matrixToString(sb, f, matrixMvit);
+ matMvit.toString(sb, null, f);
}
sb.append("]");
return sb;
@@ -1014,18 +1091,18 @@ public final class PMVMatrix implements GLMatrixFunc {
* <p>
* A dirty bit is set , if the corresponding matrix had been modified by a mutable operation
* since last {@link #update()} call. The latter clears the dirty state only if the dirty matrix (Mvi or Mvit) or {@link Frustum}
- * has been requested by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get}
- * or {@link #glGetFrustum() Frustum get} methods.
+ * has been requested by one of the {@link #getMviMat() Mvi get}, {@link #getMvitMat() Mvit get}
+ * or {@link #getFrustum() Frustum get} methods.
* </p>
*
* @see #DIRTY_INVERSE_MODELVIEW
* @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW
* @see #DIRTY_FRUSTUM
- * @see #glGetMviMatrixf()
- * @see #glGetMvitMatrixf()
+ * @see #getMviMat()
+ * @see #getMvitMat()
* @see #glGetPMvMviMatrixf()
* @see #glGetPMvMvitMatrixf()
- * @see #glGetFrustum()
+ * @see #getFrustum()
*/
public final int getDirtyBits() {
return dirtyBits;
@@ -1034,19 +1111,19 @@ public final class PMVMatrix implements GLMatrixFunc {
/**
* Returns the request bit mask, which uses bit values equal to the dirty mask.
* <p>
- * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get}
- * or {@link #glGetFrustum() Frustum get} methods.
+ * The request bit mask is set by one of the {@link #getMviMat() Mvi get}, {@link #getMvitMat() Mvit get}
+ * or {@link #getFrustum() Frustum get} methods.
* </p>
*
* @see #clearAllUpdateRequests()
* @see #DIRTY_INVERSE_MODELVIEW
* @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW
* @see #DIRTY_FRUSTUM
- * @see #glGetMviMatrixf()
- * @see #glGetMvitMatrixf()
+ * @see #getMviMat()
+ * @see #getMvitMat()
* @see #glGetPMvMviMatrixf()
* @see #glGetPMvMvitMatrixf()
- * @see #glGetFrustum()
+ * @see #getFrustum()
*/
public final int getRequestMask() {
return requestMask;
@@ -1055,17 +1132,17 @@ public final class PMVMatrix implements GLMatrixFunc {
/**
* Clears all {@link #update()} requests of the Mvi and Mvit matrix and Frustum
- * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get}
- * or {@link #glGetFrustum() Frustum get} methods.
+ * after it has been enabled by one of the {@link #getMviMat() Mvi get}, {@link #getMvitMat() Mvit get}
+ * or {@link #getFrustum() Frustum get} methods.
* <p>
* Allows user to disable subsequent Mvi, Mvit and {@link Frustum} updates if no more required.
* </p>
*
- * @see #glGetMviMatrixf()
- * @see #glGetMvitMatrixf()
+ * @see #getMviMat()
+ * @see #getMvitMat()
* @see #glGetPMvMviMatrixf()
* @see #glGetPMvMvitMatrixf()
- * @see #glGetFrustum()
+ * @see #getFrustum()
* @see #getRequestMask()
*/
public final void clearAllUpdateRequests() {
@@ -1073,20 +1150,20 @@ public final class PMVMatrix implements GLMatrixFunc {
}
/**
- * Update the derived {@link #glGetMviMatrixf() inverse modelview (Mvi)},
- * {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices and {@link Frustum}
+ * Update the derived {@link #getMviMat() inverse modelview (Mvi)},
+ * {@link #getMvitMat() inverse transposed modelview (Mvit)} matrices and {@link Frustum}
* <b>if</b> they are dirty <b>and</b> they were requested
- * by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get}
- * or {@link #glGetFrustum() Frustum get} methods.
+ * by one of the {@link #getMviMat() Mvi get}, {@link #getMvitMat() Mvit get}
+ * or {@link #getFrustum() Frustum get} methods.
* <p>
* The Mvi and Mvit matrices and {@link Frustum} are considered dirty, if their corresponding
- * {@link #glGetMvMatrixf() Mv matrix} has been modified since their last update.
+ * {@link #getMvMat() Mv matrix} has been modified since their last update.
* </p>
* <p>
* Method should be called manually in case mutable operations has been called
* and caller operates on already fetched references, i.e. not calling
- * {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get}
- * or {@link #glGetFrustum() Frustum get} etc anymore.
+ * {@link #getMviMat() Mvi get}, {@link #getMvitMat() Mvit get}
+ * or {@link #getFrustum() Frustum get} etc anymore.
* </p>
* <p>
* This method clears the modified bits like {@link #getModifiedBits(boolean) getModifiedBits(true)},
@@ -1106,11 +1183,11 @@ public final class PMVMatrix implements GLMatrixFunc {
* @see #DIRTY_INVERSE_MODELVIEW
* @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW
* @see #DIRTY_FRUSTUM
- * @see #glGetMviMatrixf()
- * @see #glGetMvitMatrixf()
+ * @see #getMviMat()
+ * @see #getMvitMat()
* @see #glGetPMvMviMatrixf()
* @see #glGetPMvMvitMatrixf()
- * @see #glGetFrustum()
+ * @see #getFrustum()
* @see #clearAllUpdateRequests()
*/
public final boolean update() {
@@ -1126,9 +1203,8 @@ public final class PMVMatrix implements GLMatrixFunc {
if( null == frustum ) {
frustum = new Frustum();
}
- FloatUtil.multMatrix(matrixArray, mP_offset, matrixArray, mMv_offset, mat4Tmp1, 0);
- // FloatUtil.multMatrix(matrixP, matrixMv, mat4Tmp1, 0);
- frustum.updateByPMV(mat4Tmp1, 0);
+ mat4Tmp1.mul(matP, matMv);
+ frustum.updateFrustumPlanes(mat4Tmp1);
dirtyBits &= ~DIRTY_FRUSTUM;
mod = true;
}
@@ -1146,35 +1222,138 @@ public final class PMVMatrix implements GLMatrixFunc {
private static final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse";
private final boolean setMviMvit() {
- final float[] _matrixMvi = matrixMvi.array();
- final int _matrixMviOffset = matrixMvi.position();
boolean res = false;
if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update()
- if( null == FloatUtil.invertMatrix(matrixArray, mMv_offset, _matrixMvi, _matrixMviOffset) ) {
+ if( !matMvi.invert(matMv) ) {
throw new GLException(msgCantComputeInverse);
}
dirtyBits &= ~DIRTY_INVERSE_MODELVIEW;
res = true;
}
if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty
- FloatUtil.transposeMatrix(_matrixMvi, _matrixMviOffset, matrixMvit.array(), matrixMvit.position());
+ matMvit.transpose(matMvi);
dirtyBits &= ~DIRTY_INVERSE_TRANSPOSED_MODELVIEW;
res = true;
}
return res;
}
- private static final int mP_offset = 0*16;
- private static final int mMv_offset = 1*16;
- private static final int mTex_offset = 4*16;
- private final float[] matrixArray;
- private final FloatBuffer matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit;
- private final float[] matrixTxSx;
- private final float[] mat4Tmp1, mat4Tmp2, mat4Tmp3;
- private final FloatStack matrixTStack, matrixPStack, matrixMvStack;
+ private final Matrix4f matP;
+ private final Matrix4f matMv;
+ private final Matrix4f matMvi;
+ private final Matrix4f matMvit;
+ private final Matrix4f matTex;
+
+ private static final int mP_offset = 0*16;
+ private static final int mMv_offset = 1*16;
+ private static final int mMvi_offset = 2*16;
+ private static final int mMvit_offset = 3*16;
+ private static final int mTex_offset = 4*16;
+
+ private final float[] matrixStore;
+ private final FloatBuffer matrixP, matrixMv, matrixMvi, matrixMvit, matrixTex;
+ private final FloatBuffer matrixPMvMvit, matrixPMvMvi, matrixPMv;
+
+ private final SyncMatrix4f matPSync, matMvSync, matMviSync, matMvitSync, matTexSync;
+ private final SyncMatrices4f matPMvMvitSync, matPMvMviSync, matPMvSync;
+
+ private final Matrix4f mat4Tmp1, mat4Tmp2;
+ private final Vec3f vec3Tmp1;
+ private final Vec4f vec4Tmp1;
+
private int matrixMode = GL_MODELVIEW;
private int modifiedBits = MODIFIED_ALL;
private int dirtyBits = DIRTY_ALL; // contains the dirty bits, i.e. hinting for update operation
private int requestMask = 0; // may contain the requested dirty bits: DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW
private Frustum frustum;
+
+ private abstract class PMVSyncBuffer implements SyncMatrix4f {
+ protected final Matrix4f mat;
+ private final FloatBuffer fbuf;
+
+ public PMVSyncBuffer(final Matrix4f m, final FloatBuffer fbuf) {
+ this.mat = m;
+ this.fbuf = fbuf;
+ }
+
+ @Override
+ public final Buffer getBuffer() { return fbuf; }
+
+ @Override
+ public final SyncBuffer sync() { getAction().sync(); return this; }
+
+ @Override
+ public final Buffer getSyncBuffer() { getAction().sync(); return fbuf; }
+
+ @Override
+ public final Matrix4f getMatrix() { return mat; }
+
+ @Override
+ public final FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; }
+ }
+ private final class SyncBuffer0 extends PMVSyncBuffer {
+ private final SyncAction action = new SyncAction() {
+ @Override
+ public void sync() { mat.get(matrixStore); }
+ };
+
+ public SyncBuffer0(final Matrix4f m, final FloatBuffer fbuf) { super(m, fbuf); }
+
+ @Override
+ public SyncAction getAction() { return action; }
+
+ }
+ private final class SyncBuffer1 extends PMVSyncBuffer {
+ private final int offset;
+ private final SyncAction action = new SyncAction() {
+ @Override
+ public void sync() { mat.get(matrixStore, offset); }
+ };
+
+ public SyncBuffer1(final Matrix4f m, final FloatBuffer fbuf, final int offset) {
+ super(m, fbuf);
+ this.offset = offset;
+ }
+
+ @Override
+ public SyncAction getAction() { return action; }
+ }
+ private final class SyncBufferN implements SyncMatrices4f {
+ private final Matrix4f[] mats;
+ private final FloatBuffer fbuf;
+ private final int offset;
+ private final SyncAction action = new SyncAction() {
+ @Override
+ public void sync() {
+ int ioff = offset;
+ for(int i=0; i<mats.length; ++i, ioff+=16) {
+ mats[i].get(matrixStore, ioff);
+ }
+ }
+ };
+
+ public SyncBufferN(final Matrix4f[] ms, final FloatBuffer fbuf, final int offset) {
+ this.mats = ms;
+ this.fbuf = fbuf;
+ this.offset = offset;
+ }
+
+ @Override
+ public SyncAction getAction() { return action; }
+
+ @Override
+ public Buffer getBuffer() { return fbuf; }
+
+ @Override
+ public SyncBuffer sync() { getAction().sync(); return this; }
+
+ @Override
+ public Buffer getSyncBuffer() { getAction().sync(); return fbuf; }
+
+ @Override
+ public Matrix4f[] getMatrices() { return mats; }
+
+ @Override
+ public FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; }
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncAction.java b/src/jogl/classes/com/jogamp/opengl/util/SyncAction.java
new file mode 100644
index 000000000..fbf55e683
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/SyncAction.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright 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.util;
+
+/**
+ * Specific data synchronization action implemented by the data provider
+ * to update the buffer with the underlying data before usage, e.g. uploading the {@link com.jogamp.opengl.GLUniformData GLUniformData} data to the GPU.
+ * <p>
+ * Example: Invoked before delivering {@link com.jogamp.opengl.GLUniformData GLUniformData}'s data via {@link com.jogamp.opengl.GLUniformData#getObject() getObject()}
+ * or {@link com.jogamp.opengl.GLUniformData#getBuffer() getBuffer()}.
+ * </p>
+ */
+public interface SyncAction {
+ /**
+ * Synchronizes the buffer with the underlying data before usage.
+ * <p>
+ * Example: {@link com.jogamp.opengl.GLUniformData GLUniformData} issues this method before delivering data via {@link com.jogamp.opengl.GLUniformData#getObject() getObject()}
+ * or {@link com.jogamp.opengl.GLUniformData#getBuffer() getBuffer()}.
+ * </p>
+ */
+ void sync();
+} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/SyncBuffer.java
new file mode 100644
index 000000000..27bdb5dfb
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/SyncBuffer.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 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.util;
+
+import java.nio.Buffer;
+
+/**
+ * Convenient tuple of a {@link SyncAction} and {@link Buffer}.
+ * <p>
+ * {@link SyncAction#sync()} is used to update the {@link Buffer} with the underlying data
+ * known to the data provider.
+ * </p>
+ * @see SyncAction
+ */
+public interface SyncBuffer {
+ /**
+ * Return the {@link SyncAction}.
+ * @see SyncAction
+ */
+ SyncAction getAction();
+
+ /** Return the {@link Buffer}, i.e. underlying data. */
+ Buffer getBuffer();
+
+ /**
+ * Synchronizes the underlying data before usage.
+ * <p>
+ * Convenient shortcut for {@link #getAction()}.{@link SyncAction#sync() sync()} plus chaining.
+ * </p>
+ */
+ SyncBuffer sync();
+
+ /** Return the {@link Buffer} after {@link SyncAction#sync() synchronizing} it. */
+ Buffer getSyncBuffer();
+
+} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f.java b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f.java
new file mode 100644
index 000000000..055345d65
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 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.util;
+
+import java.nio.FloatBuffer;
+
+import com.jogamp.opengl.math.Matrix4f;
+
+/** {@link SyncBuffer} with a multiple underlying {@link Matrix4f}, used in {@link SyncMatrices4f16} and {@link PMVMatrix} */
+public interface SyncMatrices4f extends SyncBuffer {
+ /** Return the underlying multiple {@link Matrix4f}, used to {@link SyncAction#sync() synchronize} to the {@link #getBuffer()}. */
+ Matrix4f[] getMatrices();
+
+ /** Return the {@link FloatBuffer} after {@link SyncAction#sync() synchronizing} it w/ the underlying {@link #getMatrices()}. */
+ FloatBuffer getSyncFloats();
+} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f16.java b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f16.java
new file mode 100644
index 000000000..bca827b9f
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f16.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 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.util;
+
+import java.nio.Buffer;
+import java.nio.FloatBuffer;
+
+import com.jogamp.opengl.math.Matrix4f;
+
+/** {@link SyncBuffer} {@link SyncMatrices4f16} implementation for multiple underlying {@link Matrix4f} instances using one {@code float[16*n]} backing array. */
+public final class SyncMatrices4f16 implements SyncMatrices4f {
+ private final Matrix4f[] mats;
+ private final float[] f16s;
+ private final FloatBuffer fbuf;
+ private final SyncAction action = new SyncAction() {
+ @Override
+ public void sync() {
+ int ioff = 0;
+ for(int i=0; i<mats.length; ++i, ioff+=16) {
+ mats[i].get(f16s, ioff);
+ }
+ }
+ };
+
+ public SyncMatrices4f16(final Matrix4f[] mats) {
+ this.mats = mats;
+ this.f16s = new float[16*mats.length];
+ this.fbuf = FloatBuffer.wrap(f16s);
+ }
+
+ @Override
+ public SyncAction getAction() { return action; }
+
+ @Override
+ public Buffer getBuffer() { return fbuf; }
+
+ @Override
+ public SyncBuffer sync() { getAction().sync(); return this; }
+
+ @Override
+ public Buffer getSyncBuffer() { getAction().sync(); return fbuf; }
+
+ @Override
+ public Matrix4f[] getMatrices() { return mats; }
+
+ @Override
+ public FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; }
+
+} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f.java b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f.java
new file mode 100644
index 000000000..6ab473771
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 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.util;
+
+import java.nio.FloatBuffer;
+
+import com.jogamp.opengl.math.Matrix4f;
+
+/** {@link SyncBuffer} interface with a single underlying {@link Matrix4f}, used in {@link SyncMatrix4f16} and {@link PMVMatrix}. */
+public interface SyncMatrix4f extends SyncBuffer {
+ /** Return the underlying {@link Matrix4f}, used to {@link SyncAction#sync() synchronize} to the {@link #getBuffer()}. */
+ Matrix4f getMatrix();
+
+ /** Return the {@link FloatBuffer} after {@link SyncAction#sync() synchronizing} it w/ the underlying {@link #getMatrix()}. */
+ FloatBuffer getSyncFloats();
+
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f16.java b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f16.java
new file mode 100644
index 000000000..03a4b64fa
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f16.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 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.util;
+
+import java.nio.Buffer;
+import java.nio.FloatBuffer;
+
+import com.jogamp.opengl.math.Matrix4f;
+
+/** {@link SyncBuffer} {@link SyncMatrix4f} implementation for a single underlying {@link Matrix4f} using one {@code float[16]} backing array. */
+public final class SyncMatrix4f16 implements SyncMatrix4f {
+ private final Matrix4f mat;
+ private final float[] f16;
+ private final FloatBuffer fbuf;
+ private final SyncAction action = new SyncAction() {
+ @Override
+ public void sync() { mat.get(f16); }
+ };
+
+ public SyncMatrix4f16() {
+ this.mat = new Matrix4f();
+ this.f16 = new float[16];
+ this.fbuf = FloatBuffer.wrap(f16);
+ }
+
+ public SyncMatrix4f16(final Matrix4f m) {
+ this.mat = m;
+ this.f16 = new float[16];
+ this.fbuf = FloatBuffer.wrap(f16);
+ }
+
+ @Override
+ public SyncAction getAction() { return action; }
+
+ @Override
+ public Buffer getBuffer() { return fbuf; }
+
+ @Override
+ public SyncBuffer sync() { getAction().sync(); return this; }
+
+ @Override
+ public Buffer getSyncBuffer() { getAction().sync(); return fbuf; }
+
+ @Override
+ public Matrix4f getMatrix() { return mat; }
+
+ @Override
+ public FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; }
+} \ No newline at end of file
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index c7a5a4bda..e70657b76 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -46,9 +46,11 @@ import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.SyncMatrices4f16;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
@@ -77,7 +79,9 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
private GLArrayDataServer gca_FboTexCoordsAttr;
private GLArrayDataServer indicesFbo;
private final GLUniformData gcu_FboTexUnit;
- private final float[] pmvMatrix02 = new float[2*16]; // P + Mv
+ private final Matrix4f matP = new Matrix4f();
+ private final Matrix4f matMv = new Matrix4f();
+ private final SyncMatrices4f16 pmvMatrix02 = new SyncMatrices4f16( new Matrix4f[] { matP, matMv } );
private final GLUniformData gcu_PMVMatrix02;
private ShaderProgram spPass2 = null;
@@ -110,10 +114,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
colorTexBBox = null;
gcu_ColorTexBBox = null;
}
-
- FloatUtil.makeIdentity(pmvMatrix02, 0);
- FloatUtil.makeIdentity(pmvMatrix02, 16);
- gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, FloatBuffer.wrap(pmvMatrix02));
+ gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, pmvMatrix02);
// Pass 2:
gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, pass2TexUnit);
@@ -382,11 +383,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
private final AABBox drawWinBox = new AABBox();
- private final int[] drawView = new int[] { 0, 0, 0, 0 };
- private final float[] drawVec4Tmp0 = new float[4];
- private final float[] drawVec4Tmp1 = new float[4];
- private final float[] drawVec4Tmp2 = new float[4];
- private final float[] drawMat4PMv = new float[16];
+ private final Recti drawView = new Recti();
+ private final Matrix4f drawMat4PMv = new Matrix4f();
private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border
@@ -426,12 +424,11 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
// Calculate perspective pixel width/height for FBO,
// considering the sampleCount.
- drawView[2] = vpWidth;
- drawView[3] = vpHeight;
+ drawView.setWidth(vpWidth);
+ drawView.setHeight(vpHeight);
- renderer.getMatrix().multPMvMatrixf(drawMat4PMv, 0);
- box.mapToWindow(drawWinBox, drawMat4PMv, drawView, true /* useCenterZ */,
- drawVec4Tmp0, drawVec4Tmp1, drawVec4Tmp2);
+ renderer.getMatrix().mulPMvMat(drawMat4PMv);
+ box.mapToWindow(drawWinBox, drawMat4PMv, drawView, true /* useCenterZ */);
winWidth = drawWinBox.getWidth();
winHeight = drawWinBox.getHeight();
@@ -459,8 +456,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
System.err.printf("XXX.MinMax obj d[%.3f, %.3f], r[%f, %f], b[%f, %f]%n",
diffObjWidth, diffObjHeight, ratioObjWinWidth, ratioObjWinWidth, diffObjBorderWidth, diffObjBorderHeight);
System.err.printf("XXX.MinMax win %s%n", drawWinBox.toString());
- System.err.printf("XXX.MinMax view[%d, %d] -> win[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f]: FBO i[%d x %d], samples %d%n",
- drawView[2], drawView[3],
+ System.err.printf("XXX.MinMax view[%s] -> win[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f]: FBO i[%d x %d], samples %d%n",
+ drawView, drawView,
winWidth, winHeight, targetWinWidth, targetWinHeight, diffWinWidth,
diffWinHeight, ratioWinWidth, ratioWinHeight,
targetFboWidth, targetFboHeight,
@@ -496,7 +493,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
fb.position(12);
}
gca_FboVerticesAttr.seal(true);
- FloatUtil.makeOrtho(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1);
+ matP.setToOrtho(minX, maxX, minY, maxY, -1, 1);
useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
} else if( isStateDirty() ) {
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 55f31a161..844ba5e38 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -50,9 +50,11 @@ import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
import com.jogamp.opengl.FBObject.TextureAttachment;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.opengl.math.Recti;
import com.jogamp.opengl.math.geom.AABBox;
-import com.jogamp.opengl.util.GLArrayDataClient;
import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.SyncMatrices4f16;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
@@ -112,7 +114,9 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
private GLArrayDataServer indicesFbo;
private final GLUniformData gcu_FboTexUnit;
private final GLUniformData gcu_FboTexSize;
- private final float[] pmvMatrix02 = new float[2*16]; // P + Mv
+ private final Matrix4f matP = new Matrix4f();
+ private final Matrix4f matMv = new Matrix4f();
+ private final SyncMatrices4f16 pmvMatrix02 = new SyncMatrices4f16( new Matrix4f[] { matP, matMv } );
private final GLUniformData gcu_PMVMatrix02;
private ShaderProgram spPass2 = null;
@@ -203,10 +207,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
colorTexBBox = null;
gcu_ColorTexBBox = null;
}
-
- FloatUtil.makeIdentity(pmvMatrix02, 0);
- FloatUtil.makeIdentity(pmvMatrix02, 16);
- gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, FloatBuffer.wrap(pmvMatrix02));
+ gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, pmvMatrix02);
// Pass 2:
gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, pass2TexUnit);
@@ -444,11 +445,9 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
}
private final AABBox drawWinBox = new AABBox();
- private final int[] drawView = new int[] { 0, 0, 0, 0 };
- private final float[] drawVec4Tmp0 = new float[4];
- private final float[] drawVec4Tmp1 = new float[4];
- private final float[] drawVec4Tmp2 = new float[4];
- private final float[] drawMat4PMv = new float[16];
+ private final Recti drawView = new Recti();
+ private final Matrix4f drawMat4PMv = new Matrix4f();
+
private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border
@Override
@@ -487,12 +486,11 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
// Calculate perspective pixel width/height for FBO,
// considering the sampleCount.
- drawView[2] = vpWidth;
- drawView[3] = vpHeight;
+ drawView.setWidth(vpWidth);
+ drawView.setHeight(vpHeight);
- renderer.getMatrix().multPMvMatrixf(drawMat4PMv, 0);
- box.mapToWindow(drawWinBox, drawMat4PMv, drawView, true /* useCenterZ */,
- drawVec4Tmp0, drawVec4Tmp1, drawVec4Tmp2);
+ renderer.getMatrix().mulPMvMat(drawMat4PMv);
+ box.mapToWindow(drawWinBox, drawMat4PMv, drawView, true /* useCenterZ */);
winWidth = drawWinBox.getWidth();
winHeight = drawWinBox.getHeight();
@@ -529,8 +527,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
System.err.printf("XXX.MinMax obj d[%.3f, %.3f], r[%f, %f], b[%f, %f]%n",
diffObjWidth, diffObjHeight, ratioObjWinWidth, ratioObjWinWidth, diffObjBorderWidth, diffObjBorderHeight);
System.err.printf("XXX.MinMax win %s%n", drawWinBox.toString());
- System.err.printf("XXX.MinMax view[%d, %d] -> win[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f], samples %d%n",
- drawView[2], drawView[3],
+ System.err.printf("XXX.MinMax view[%s] -> win[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f], samples %d%n",
+ drawView,
winWidth, winHeight, targetWinWidth, targetWinHeight, diffWinWidth,
diffWinHeight, ratioWinWidth, ratioWinHeight,
renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
@@ -632,7 +630,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
fb.position(12);
}
gca_FboVerticesAttr.seal(true);
- FloatUtil.makeOrtho(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1);
+ matP.setToOrtho(minX, maxX, minY, maxY, -1, 1);
useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]);
} else if( isStateDirty() ) {
diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java
index 3fcc75f3d..cc4640534 100644
--- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java
+++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java
@@ -618,7 +618,7 @@ public class ProjectFloat {
final float x, final float y,
final float deltaX, final float deltaY,
final int[] viewport, final int viewport_offset) {
- if( null != FloatUtil.makePick(mat4Tmp1, 0, x, y, deltaX, deltaY, viewport, viewport_offset, mat4Tmp2) ) {
+ if( null != FloatUtil.makePick(mat4Tmp1, x, y, deltaX, deltaY, viewport, viewport_offset, mat4Tmp2) ) {
gl.glMultMatrixf(mat4Tmp1, 0);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index c671a743b..20a433aa9 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -204,7 +204,7 @@ public class MacOSXCGLContext extends GLContextImpl
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
pmvMatrixUniform.setLocation(gl, sp.program());
gl.glUniform(pmvMatrixUniform);
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java
index 66c5c855b..72c7c257f 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java
@@ -87,7 +87,7 @@ public class GLSLTextureRaster {
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
if( pmvMatrixUniform.setLocation(gl, sp.program()) < 0 ) {
throw new GLException("Couldn't locate "+pmvMatrixUniform+" in shader: "+sp);
}
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
index 5ac1dc7bf..6b7317dd6 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -38,6 +38,7 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GL2ES1;
import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GL2ES3;
import com.jogamp.opengl.GL2GL3;
import com.jogamp.opengl.GLArrayData;
import com.jogamp.opengl.GLES2;
@@ -54,6 +55,7 @@ import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.IntIntHashMap;
import com.jogamp.common.util.PropertyAccess;
import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.SyncBuffer;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -714,7 +716,7 @@ public class FixedFuncPipeline {
return;
}
validate(gl, true);
- if ( GL2GL3.GL_QUADS == mode && !gl.isGL2() ) {
+ if ( GL2ES3.GL_QUADS == mode && !gl.isGL2() ) {
for (int j = first; j < count - 3; j += 4) {
gl.glDrawArrays(GL.GL_TRIANGLE_FAN, j, 4);
}
@@ -724,7 +726,7 @@ public class FixedFuncPipeline {
}
public void glDrawElements(final GL2ES2 gl, final int mode, final int count, final int type, final java.nio.Buffer indices) {
validate(gl, true);
- if ( GL2GL3.GL_QUADS == mode && !gl.isGL2() ) {
+ if ( GL2ES3.GL_QUADS == mode && !gl.isGL2() ) {
final int idx0 = indices.position();
if( GL.GL_UNSIGNED_BYTE == type ) {
@@ -758,7 +760,7 @@ public class FixedFuncPipeline {
}
public void glDrawElements(final GL2ES2 gl, final int mode, final int count, final int type, final long indices_buffer_offset) {
validate(gl, true);
- if ( GL2GL3.GL_QUADS == mode && !gl.isGL2() ) {
+ if ( GL2ES3.GL_QUADS == mode && !gl.isGL2() ) {
throw new GLException("Cannot handle indexed QUADS on !GL2 w/ VBO due to lack of CPU index access");
} else /* if( GL.GL_POINTS != mode ) */ {
gl.glDrawElements(mode, count, type, indices_buffer_offset);
@@ -814,12 +816,12 @@ public class FixedFuncPipeline {
if( pmvMatrix.update() ) {
ud = shaderState.getUniform(mgl_PMVMatrix);
if(null!=ud) {
- final FloatBuffer m;
+ final SyncBuffer m;
if(ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX == currentShaderSelectionMode ||
ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) {
- m = pmvMatrix.glGetPMvMvitMatrixf();
+ m = pmvMatrix.getSyncPMvMvitMat();
} else {
- m = pmvMatrix.glGetPMvMatrixf();
+ m = pmvMatrix.getSyncPMvMat();
}
if(m != ud.getBuffer()) {
ud.setData(m);
@@ -1111,7 +1113,7 @@ public class FixedFuncPipeline {
shaderState.attachShaderProgram(gl, selectShaderProgram(gl, requestedShaderSelectionMode), true);
// mandatory ..
- if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMvitMatrixf()))) {
+ if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.getSyncPMvMvitMat()))) {
throw new GLException("Error setting PMVMatrix in shader: "+this);
}
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);