aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-20 19:51:55 +0200
committerSven Gothel <[email protected]>2023-09-20 19:51:55 +0200
commit5d6e8a367c03644740187e500c6de5d3ac039d5e (patch)
treea649f559413c51272ee3f4afff1f68ebfea45477 /src/jogl/classes/jogamp/opengl/util
parentbbe845846ffc00807395a5070a7352c6bbe7e4ef (diff)
Bug 1452 - Decouple math functionality to 'com.jogamp.math' to be toolkit agnostic (PMVMatrix, Matrix4f, Vec4f, ..)
Math functionality (PMVMatrix, Matrix4f, Vec4f, ..) - shall be used toolkit agnostic, e.g. independent from OpenGL - shall be reused within our upcoming Vulkan implementation - may also move outside of JOGL, i.e. GlueGen or within its own package to be reused for other purposed. The 'com.jogamp.opengl.util.PMVMatrix' currently also used to feed in GLUniformData via the toolkit agnostic SyncAction and SyncBuffer shall also be split to a toolkit agnostic variant. An OpenGL PMVMatrix specialization implementing GLMatrixFunc can still exist, being derived from the toolkit agnostic base implementation. +++ Initial commit .. compile clean, passing most unit tests.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java1
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java5
7 files changed, 29 insertions, 34 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 94b666b7b..7d517c2d6 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -1459,6 +1459,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
isBlocked = false;
} catch (final Throwable t) {
streamErr = new StreamException(t.getClass().getSimpleName()+" while decoding: "+GLMediaPlayerImpl.this.toString(), t);
+ isBlocked = false;
} finally {
if( null != nextFrame ) { // put back
videoFramesFree.put(nextFrame);
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java
index 72c7c257f..e39def369 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java
@@ -31,23 +31,21 @@ package jogamp.opengl.util.glsl;
import java.nio.FloatBuffer;
import com.jogamp.opengl.util.GLArrayDataServer;
-import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
-
+import com.jogamp.math.util.PMVMatrix4f;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLArrayData;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLUniformData;
-import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
public class GLSLTextureRaster {
private final boolean textureVertFlipped;
private final int textureUnit;
private ShaderProgram sp;
- private PMVMatrix pmvMatrix;
+ private PMVMatrix4f pmvMatrix;
private GLUniformData pmvMatrixUniform;
private GLUniformData activeTexUniform;
private GLArrayDataServer interleavedVBO;
@@ -82,12 +80,10 @@ public class GLSLTextureRaster {
sp.useProgram(gl, true);
// setup mgl_PMVMatrix
- pmvMatrix = new PMVMatrix();
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
+ pmvMatrix = new PMVMatrix4f();
+ pmvMatrix.loadPIdentity();
+ pmvMatrix.loadMvIdentity();
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv
if( pmvMatrixUniform.setLocation(gl, sp.program()) < 0 ) {
throw new GLException("Couldn't locate "+pmvMatrixUniform+" in shader: "+sp);
}
@@ -130,12 +126,10 @@ public class GLSLTextureRaster {
public void reshape(final GL2ES2 gl, final int x, final int y, final int width, final int height) {
if(null != sp) {
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
+ pmvMatrix.loadPIdentity();
+ pmvMatrix.orthoP(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmvMatrix.glLoadIdentity();
+ pmvMatrix.loadMvIdentity();
sp.useProgram(gl, true);
gl.glUniform(pmvMatrixUniform);
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 998406856..fb2bf1bdc 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
@@ -43,6 +43,7 @@ import com.jogamp.opengl.fixedfunc.GLPointerFunc;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.ValueConv;
+import com.jogamp.math.util.PMVMatrix4f;
import com.jogamp.opengl.util.GLArrayDataWrapper;
import com.jogamp.opengl.util.GLBuffers;
import com.jogamp.opengl.util.PMVMatrix;
@@ -70,7 +71,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
this.pmvMatrix = pmvMatrix;
} else {
this.ownsPMVMatrix = true;
- this.pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW);
+ this.pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW);
}
fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix);
}
@@ -91,7 +92,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
this.pmvMatrix = pmvMatrix;
} else {
this.ownsPMVMatrix = true;
- this.pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW);
+ this.pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW);
}
fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot,
@@ -109,7 +110,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
gl=null;
}
- public PMVMatrix getMatrix() { return pmvMatrix; }
+ public PMVMatrix4f getMatrix() { return pmvMatrix; }
//
// FixedFuncHookIf - hooks
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 c9e2664ba..a4b5e9afd 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -54,9 +54,9 @@ import jogamp.opengl.Debug;
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.SyncMatrices4f;
+import com.jogamp.math.util.PMVMatrix4f;
+import com.jogamp.math.util.SyncBuffer;
+import com.jogamp.math.util.SyncMatrices4f;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -82,7 +82,7 @@ public class FixedFuncPipeline {
public static final int MAX_TEXTURE_UNITS = 8;
public static final int MAX_LIGHTS = 8;
- public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) {
+ public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix) {
shaderRootClass = FixedFuncPipeline.class;
shaderSrcRoot = shaderSrcRootDef;
shaderBinRoot = shaderBinRootDef;
@@ -92,7 +92,7 @@ public class FixedFuncPipeline {
fragmentColorTextureFile = fragmentColorTextureFileDef;
init(gl, mode, pmvMatrix);
}
- public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix,
+ public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix,
final Class<?> shaderRootClass, final String shaderSrcRoot,
final String shaderBinRoot,
final String vertexColorFile, final String vertexColorLightFile,
@@ -820,9 +820,9 @@ public class FixedFuncPipeline {
final SyncMatrices4f m;
if(ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX == currentShaderSelectionMode ||
ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) {
- m = pmvMatrix.getSyncPMvMviMvitMat();
+ m = pmvMatrix.getSyncPMvMviMvit();
} else {
- m = pmvMatrix.getSyncPMvMat();
+ m = pmvMatrix.getSyncPMv();
}
if(m != ud.getBuffer()) {
ud.setData(m);
@@ -1102,7 +1102,7 @@ public class FixedFuncPipeline {
return sp;
}
- private void init(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) {
+ private void init(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix) {
if(null==pmvMatrix) {
throw new GLException("PMVMatrix is null");
}
@@ -1114,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.getSyncPMvMviMvitMat()))) {
+ if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.getSyncPMvMviMvit()))) {
throw new GLException("Error setting PMVMatrix in shader: "+this);
}
@@ -1202,7 +1202,7 @@ public class FixedFuncPipeline {
/** ( pointSize, pointSmooth, attn. pointMinSize, attn. pointMaxSize ) , ( attenuation coefficients 1f 0f 0f, attenuation fade theshold 1f ) */
private final FloatBuffer pointParams = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f });
- private PMVMatrix pmvMatrix;
+ private PMVMatrix4f pmvMatrix;
private ShaderState shaderState;
private ShaderProgram shaderProgramColor;
private ShaderProgram shaderProgramColorTexture2, shaderProgramColorTexture4, shaderProgramColorTexture8;
diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java
index 60adc7d74..89765e4f6 100644
--- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java
+++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java
@@ -27,14 +27,14 @@
*/
package jogamp.opengl.util.stereo;
+import com.jogamp.math.FovHVHalves;
+import com.jogamp.math.Vec3f;
import com.jogamp.nativewindow.util.Dimension;
import com.jogamp.nativewindow.util.DimensionImmutable;
import com.jogamp.nativewindow.util.Point;
import com.jogamp.nativewindow.util.PointImmutable;
import com.jogamp.nativewindow.util.Rectangle;
import com.jogamp.nativewindow.util.RectangleImmutable;
-import com.jogamp.opengl.math.FovHVHalves;
-import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.stereo.StereoDeviceConfig;
import com.jogamp.opengl.util.stereo.EyeParameter;
import com.jogamp.opengl.util.stereo.LocationSensorParameter;
diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java
index 3c6f5e37e..3a3ead790 100644
--- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java
+++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java
@@ -44,8 +44,8 @@ import jogamp.common.os.PlatformPropsImpl;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.os.Platform;
+import com.jogamp.math.Vec3f;
import com.jogamp.opengl.JoglVersion;
-import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java b/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java
index 1fed69363..f7a5a5e9b 100644
--- a/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java
+++ b/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java
@@ -27,12 +27,11 @@
*/
package jogamp.opengl.util.stereo;
+import com.jogamp.math.FovHVHalves;
+import com.jogamp.math.VectorUtil;
import com.jogamp.nativewindow.util.DimensionImmutable;
import com.jogamp.nativewindow.util.RectangleImmutable;
-import com.jogamp.opengl.math.FovHVHalves;
-import com.jogamp.opengl.math.VectorUtil;
-
/**
* 2D scale and offset NDC class,
* providing conversion from {@link FovHVHalves} in tangent to NDC space.