diff options
author | Sven Gothel <sgothel@jausoft.com> | 2023-09-20 19:51:55 +0200 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2023-09-20 19:51:55 +0200 |
commit | 5d6e8a367c03644740187e500c6de5d3ac039d5e (patch) | |
tree | a649f559413c51272ee3f4afff1f68ebfea45477 /src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java | |
parent | bbe845846ffc00807395a5070a7352c6bbe7e4ef (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/glsl/GLSLTextureRaster.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java | 24 |
1 files changed, 9 insertions, 15 deletions
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); |