diff options
author | Sven Gothel <[email protected]> | 2023-04-09 08:26:57 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-09 08:26:57 +0200 |
commit | df60909c70b5dba10c9734e0c26d31e0649f4309 (patch) | |
tree | e600920890e52670c2749ce70f70b1913d77dd3c /src/jogl/classes/jogamp/opengl/util | |
parent | 003eb8ca1f296f287dc3d224fa19781705e10dd9 (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/jogl/classes/jogamp/opengl/util')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java | 4 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java index 9cd8c863f..998406856 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java @@ -70,7 +70,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun this.pmvMatrix = pmvMatrix; } else { this.ownsPMVMatrix = true; - this.pmvMatrix = new PMVMatrix(); + this.pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); } fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix); } @@ -91,7 +91,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun this.pmvMatrix = pmvMatrix; } else { this.ownsPMVMatrix = true; - this.pmvMatrix = new PMVMatrix(); + this.pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); } fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot, 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 6b7317dd6..c9e2664ba 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -56,6 +56,7 @@ 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.SyncMatrices4f; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; @@ -813,13 +814,13 @@ public class FixedFuncPipeline { } GLUniformData ud; - if( pmvMatrix.update() ) { + if( pmvMatrix.isReqDirty() ) { ud = shaderState.getUniform(mgl_PMVMatrix); if(null!=ud) { - final SyncBuffer m; + final SyncMatrices4f m; if(ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX == currentShaderSelectionMode || ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) { - m = pmvMatrix.getSyncPMvMvitMat(); + m = pmvMatrix.getSyncPMvMviMvitMat(); } else { m = pmvMatrix.getSyncPMvMat(); } @@ -827,7 +828,7 @@ public class FixedFuncPipeline { ud.setData(m); } // same data object .. - shaderState.uniform(gl, ud); + shaderState.uniform(gl, ud); // automatic sync + update of Mvi + Mvit } else { throw new GLException("Failed to update: mgl_PMVMatrix"); } @@ -1113,7 +1114,7 @@ public class FixedFuncPipeline { shaderState.attachShaderProgram(gl, selectShaderProgram(gl, requestedShaderSelectionMode), true); // mandatory .. - if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.getSyncPMvMvitMat()))) { + if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.getSyncPMvMviMvitMat()))) { throw new GLException("Error setting PMVMatrix in shader: "+this); } |