summaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-09 08:26:57 +0200
committerSven Gothel <[email protected]>2023-04-09 08:26:57 +0200
commitdf60909c70b5dba10c9734e0c26d31e0649f4309 (patch)
treee600920890e52670c2749ce70f70b1913d77dd3c /src/demos/com/jogamp/opengl
parent003eb8ca1f296f287dc3d224fa19781705e10dd9 (diff)
Matrix4f.mapWin*(): Drop unused temp matrices, map*() returns false on invPMv null; PMVMatrix: Make Mvi, Mvit optional at ctor, add user PMv and PMvi - used at gluUnProject() ..
Matrix4f.mapWin*() variants w/ invPMv don't need temp matrices, they also shall handle null invPMv -> return false to streamline usage w/ PMVMatrix if inversion failed. PMVMatrix adds user space common premultiplies Pmv and Pmvi on demand like Frustum. These are commonly required for e.g. gluUnProject(..)/mapWinToObj(..) and might benefit from caching if stack is maintained and no modification occured. PMVMatrix now has the shader related Mvi and Mvit optional at construction(!), so its backing buffers. This reduces footprint for other use cases. The 2nd temp matrix is also on-demand, to reduce footprint for certain use cases. Removed public access to temporary storage. +++ While these additional matrices are on demand and/or at request @ ctor, general memory footprint is reduced per default and hence deemed acceptable while still having PMVMatrix acting as a core flexible matrix provider.
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/GearsES2.java4
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/GearsObjectES2.java6
2 files changed, 3 insertions, 7 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
index 76ee32301..194397a37 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
@@ -231,9 +231,9 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
- pmvMatrix = new PMVMatrix();
+ pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW);
st.attachObject("pmvMatrix", pmvMatrix);
- pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMvitMat()); // P, Mv, Mvi and Mvit
+ pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvitMat()); // P, Mv, Mvi and Mvit
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsObjectES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsObjectES2.java
index 3aa6696df..9caa4418a 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/GearsObjectES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/GearsObjectES2.java
@@ -123,11 +123,7 @@ public class GearsObjectES2 extends GearsObject {
pmvMatrix.glPushMatrix();
pmvMatrix.glTranslatef(x, y, 0f);
pmvMatrix.glRotatef(angle, 0f, 0f, 1f);
- if( pmvMatrix.update() ) {
- st.uniform(gl, pmvMatrixUniform);
- } else {
- throw new InternalError("PMVMatrix.update() returns false after mutable operations");
- }
+ st.uniform(gl, pmvMatrixUniform); // automatic sync + update of Mvi + Mvit
colorUniform.setData(gearColor);
st.uniform(gl, colorUniform);