aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-07 08:46:18 +0200
committerSven Gothel <[email protected]>2023-04-07 08:46:18 +0200
commit84a6d63205ec49ddfb36b57fe2888425ecda3a5a (patch)
tree354cec2ac14a8932a01122c5234926e774ef874e /src/jogl/classes/jogamp/graph/curve/opengl
parent10b60e10ece3cbc3e0b8a68ac73229371530e0ba (diff)
PMVMatrix rewrite using Matrix4f, providing SyncMatrix4f* for GLUniformData; Utilize Vec3f, Recti, .. throughout API (Matrix4f, AABBox, .. Graph*)
Big Easter Cleanup - Net -214 lines of code, despite new classes. - GLUniformData buffer can be synced w/ underlying data via SyncAction/SyncBuffer, e.g. SyncMatrix4f + SyncMatrices4f - PMVMatrix rewrite using Matrix4f and providing SyncMatrix4f/Matrices4f to sync w/ GLUniformData - Additional SyncMatrix4f16 + SyncMatrices4f16 covering Matrix4f sync w/ GLUniformData w/o PMVMatrix - Utilize Vec3f, Recti, .. throughout API (Matrix4f, AABBox, .. Graph*) - Moved FloatUtil -> Matrix4f, kept a few basic matrix ops for ProjectFloat - Most, if not all, float[] and int[] should have been moved to proper classes - int[] -> Recti for viewport rectangle - Matrix4f and PMVMatrix is covered by math unit tests (as was FloatUtil before) -> save Passed all unit tests on AMD64 GNU/Linux
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java35
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java36
2 files changed, 33 insertions, 38 deletions
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() ) {