diff options
Diffstat (limited to 'src/demos/com/jogamp/opengl')
30 files changed, 259 insertions, 288 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java index c95d8447d..7fe8f821c 100644 --- a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java +++ b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java @@ -48,6 +48,11 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -61,11 +66,6 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.graph.TextRendererGLELBase; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; @@ -466,7 +466,7 @@ public class MovieSBSStereo implements StereoGLEventListener { final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); pmvMatrix = new PMVMatrix(); reshapePMV(viewPort.width(), viewPort.height()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } @@ -494,8 +494,8 @@ public class MovieSBSStereo implements StereoGLEventListener { System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]); final Vec3f winLB = new Vec3f(); final Vec3f winRT = new Vec3f(); - pmvMatrix.gluProject(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); - pmvMatrix.gluProject(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); + pmvMatrix.mapObjToWin(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); + pmvMatrix.mapObjToWin(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); System.err.println("XXX0: win LB: "+winLB); System.err.println("XXX0: win RT: "+winRT); } diff --git a/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java b/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java index 1097b37d8..d54498228 100644 --- a/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java @@ -45,14 +45,14 @@ import com.jogamp.opengl.demos.util.QuitAdapter; import jogamp.opengl.util.stereo.GenericStereoDevice; import com.jogamp.common.net.Uri; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.opengl.util.stereo.StereoDeviceUtil; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.util.av.GLMediaPlayer; diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java index 235957c06..7de905d02 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java @@ -24,6 +24,10 @@ import java.nio.FloatBuffer; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.VersionUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.nativewindow.NativeWindow; import com.jogamp.newt.Window; import com.jogamp.newt.event.GestureHandler; @@ -49,9 +53,6 @@ import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.GearsObject; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.PMVMatrix; @@ -182,7 +183,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen public void setUseMappedBuffers(final boolean v) { useMappedBuffers = v; } public void setValidateBuffers(final boolean v) { validateBuffers = v; } - public PMVMatrix getPMVMatrix() { + public PMVMatrix4f getPMVMatrix() { return pmvMatrix; } @@ -239,9 +240,9 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); st.attachObject("pmvMatrix", pmvMatrix); - pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvitMat()); // P, Mv, Mvi and Mvit + pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvit()); // P, Mv, Mvi and Mvit st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java index 15f146a26..9b539ed61 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java @@ -31,6 +31,7 @@ import java.nio.FloatBuffer; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.VersionUtil; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -51,7 +52,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.demos.PointsDemo; import com.jogamp.opengl.demos.util.CommandlineOptions; @@ -121,7 +121,7 @@ public class PointsDemoES2 extends PointsDemo { pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java b/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java index da8235c8f..db35b6dc4 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java @@ -126,7 +126,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java index 5aa43b073..70981a53d 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java @@ -38,8 +38,8 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.common.os.Platform; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -225,7 +225,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { pmvMatrix = new PMVMatrix(); reshapePMV(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } diff --git a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java index 8496f3ee8..a8064db08 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java @@ -31,6 +31,9 @@ package com.jogamp.opengl.demos.es2; import java.nio.FloatBuffer; import com.jogamp.common.os.Platform; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; @@ -40,9 +43,6 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -169,7 +169,7 @@ public class TextureSequenceES2 implements GLEventListener { final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); pmvMatrix = new PMVMatrix(); reshapePMV(viewPort.width(), viewPort.height()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } @@ -205,8 +205,8 @@ public class TextureSequenceES2 implements GLEventListener { System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]); final Vec3f winLB = new Vec3f(); final Vec3f winRT = new Vec3f(); - pmvMatrix.gluProject(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); - pmvMatrix.gluProject(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); + pmvMatrix.mapObjToWin(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); + pmvMatrix.mapObjToWin(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); System.err.println("XXX0: win LB: "+winLB); System.err.println("XXX0: win RT: "+winRT); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java index 866d6623d..1f49bf8f5 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java @@ -33,10 +33,11 @@ import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Vec4f; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.Vec4f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.util.PMVMatrix; @@ -117,11 +118,10 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java index e5699a2d6..413adca80 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java @@ -32,12 +32,13 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Vec4f; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.geom.plane.Path2F; -import com.jogamp.graph.geom.plane.WindingRule; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.plane.Path2F; +import com.jogamp.math.geom.plane.WindingRule; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.util.PMVMatrix; @@ -282,11 +283,10 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java index 42b42a719..a802ce386 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java @@ -41,6 +41,7 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.util.PMVMatrix; @@ -123,11 +124,10 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java index 8655def4a..ebc8846e3 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java @@ -39,23 +39,22 @@ import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * @@ -110,7 +109,8 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { public final float getZTran() { return zTran; } public final float getXTran() { return xTran; } public final float getYTran() { return yTran; } - public final float getAngle() { return ang; } + public final float getAngleDeg() { return ang; } + public final float getAngleRad() { return FloatUtil.adegToRad(ang); } public final int[] getSampleCount() { return sampleCount; } public final float[] getPosition() { return position; } @@ -149,20 +149,19 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { getRenderer().init(gl); } - public static void mapWin2ObjectCoords(final PMVMatrix pmv, final Recti view, + public static void mapWin2ObjectCoords(final PMVMatrix4f pmv, final Recti view, final float zNear, final float zFar, final float orthoX, final float orthoY, final float orthoDist, final float[] winZ, final Vec3f objPos) { winZ[0] = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar); - pmv.gluUnProject(orthoX, orthoY, winZ[0], view, objPos); + pmv.mapWinToObj(orthoX, orthoY, winZ[0], view, objPos); } @Override public void reshape(final GLAutoDrawable drawable, final int xstart, final int ystart, final int width, final int height) { - final PMVMatrix pmv = renderer.getMatrix(); + final PMVMatrix4f pmv = renderer.getMatrix(); renderer.reshapePerspective(FloatUtil.QUARTER_PI, width, height, zNear, zFar); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + pmv.loadMvIdentity(); System.err.printf("Reshape: zNear %f, zFar %f%n", zNear, zFar); System.err.printf("Reshape: Frustum: %s%n", pmv.getFrustum()); { diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java index 0c85ca1a0..25eae1156 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java @@ -30,7 +30,6 @@ package com.jogamp.opengl.demos.graph; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.geom.AABBox; import java.io.File; import java.io.IOException; @@ -40,6 +39,7 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java index a5fac1270..16d8aa1db 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java @@ -35,7 +35,6 @@ import com.jogamp.opengl.GLAnimatorControl; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; @@ -46,14 +45,13 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; /** * @@ -302,9 +300,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; final RegionRenderer renderer = getRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); final float pixelSizeFName = FontScale.toPixels(fontSizeFName, dpiV); final float pixelSizeHead = FontScale.toPixels(fontSizeHead, dpiV); @@ -315,7 +312,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB renderer.enable(gl, true); if( drawFPS ) { - pmv.glPushMatrix(); + pmv.pushMv(); final float pixelSizeFPS = FontScale.toPixels(fontSizeFPS, dpiV); final float lfps, tfps; final GLAnimatorControl animator = drawable.getAnimator(); @@ -336,58 +333,58 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB drawable.getChosenGLCapabilities().getAlphaBits()); // bottom, half line up - pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); + pmv.translateMv(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeFPS; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // No cache, keep region alive! TextRegionUtil.drawString3D(gl, regionFPS.clear(gl), renderer, font, text, null, sampleCountFPS, tempT1, tempT2); - pmv.glPopMatrix(); + pmv.popMv(); } // float dx = width - ( fontNameBox.getWidth() + font.getAdvanceWidth( Glyph.ID_SPACE ) ) * pixelSizeFName; float dx = width - ( fontNameBox.getWidth() + 2 * font.getAdvanceWidth( font.getGlyphID('X') ) ) * pixelSizeFName; float dy = height - fontNameBox.getHeight() * pixelSizeFName; { - pmv.glPushMatrix(); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.pushMv(); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeFName; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // System.err.printf("FontN: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); textRegionUtil.drawString3D(gl, renderer, font, fontName, null, getSampleCount()); - pmv.glPopMatrix(); + pmv.popMv(); } dx = 10f; dy += -fontNameBox.getHeight() * pixelSizeFName - 10f; if(null != headtext) { - pmv.glPushMatrix(); + pmv.pushMv(); // System.err.printf("Head: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeHead; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // pmv.glTranslatef(x0, y1, z0); textRegionUtil.drawString3D(gl, renderer, font, headtext, null, getSampleCount()); - pmv.glPopMatrix(); + pmv.popMv(); } dy += ( -headbox.getHeight() - font.getLineHeight() ) * pixelSizeCenter; { - pmv.glPushMatrix(); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.pushMv(); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); // System.err.printf("Bottom: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); { final float sxy = nearPlaneS * pixelSizeCenter; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } renderer.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); @@ -407,7 +404,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRegionUtil.drawString3D(gl, renderer, font, userString.toString(), null, getSampleCount()); } } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); } @@ -488,7 +485,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB public boolean isUserInputMode() { return userInput; } void dumpMatrix(final boolean bbox) { - System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngle() +" fontSize "+fontSizeCenter); + System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngleDeg() +" fontSize "+fontSizeCenter); if(bbox) { System.err.println("bbox em: "+font.getMetricBounds(text2)); System.err.println("bbox px: "+font.getMetricBounds(text2).scale( nearPlaneS * FontScale.toPixels(fontSizeCenter, dpiV) ) ); diff --git a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java index 438457993..1f89fb40e 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java +++ b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java @@ -32,7 +32,6 @@ import java.io.IOException; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; @@ -42,9 +41,9 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; -import com.jogamp.opengl.util.PMVMatrix; public abstract class TextRendererGLELBase implements GLEventListener { public final int renderModes; @@ -53,7 +52,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { protected final float[] staticRGBAColor = new float[] { 1f, 1f, 1f, 1f }; private boolean exclusivePMVMatrix = true; - private PMVMatrix sharedPMVMatrix = null; + private PMVMatrix4f sharedPMVMatrix = null; private RegionRenderer.GLCallback enableCallback=null, disableCallback=null; protected RegionRenderer renderer = null; protected TextRegionUtil textRenderUtil = null; @@ -105,7 +104,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { * Must be called before {@link #init(GLAutoDrawable)}. * </p> */ - public void setSharedPMVMatrix(final PMVMatrix pmv) { + public void setSharedPMVMatrix(final PMVMatrix4f pmv) { this.sharedPMVMatrix = pmv; } @@ -125,7 +124,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { public final TextRegionUtil getTextRenderUtil() { return textRenderUtil; } public int[] getVBAASampleCount() { return this.vbaaSampleCount; } - public PMVMatrix getMatrix() { return renderer.getMatrix(); }; + public PMVMatrix4f getMatrix() { return renderer.getMatrix(); }; public boolean isMatrixShared() { return !exclusivePMVMatrix; }; @Override @@ -249,18 +248,17 @@ public abstract class TextRendererGLELBase implements GLEventListener { dx += sxy * font.getAdvanceWidth('X') * column; dy -= sxy * lineHeight * ( row + 1 ); - final PMVMatrix pmvMatrix = getMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmvMatrix = getMatrix(); if( !exclusivePMVMatrix ) { - pmvMatrix.glPushMatrix(); + pmvMatrix.pushMv(); } else { - pmvMatrix.glLoadIdentity(); + pmvMatrix.loadMvIdentity(); } - pmvMatrix.glTranslatef(dx, dy, tz); + pmvMatrix.translateMv(dx, dy, tz); if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { - pmvMatrix.glScalef(sxy, -1f*sxy, 1.0f); + pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f); } else { - pmvMatrix.glScalef(sxy, sxy, 1.0f); + pmvMatrix.scaleMv(sxy, sxy, 1.0f); } renderer.enable(gl, true); if( cacheRegion ) { @@ -273,7 +271,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { renderer.enable(gl, false); if( !exclusivePMVMatrix ) { - pmvMatrix.glPopMatrix(); + pmvMatrix.popMv(); } lastRow = row + newLineCount; } @@ -299,25 +297,24 @@ public abstract class TextRendererGLELBase implements GLEventListener { dx += sxy * font.getAdvanceWidth('X') * column; dy -= sxy * lineHeight * ( row + 1 ); - final PMVMatrix pmvMatrix = getMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmvMatrix = getMatrix(); if( !exclusivePMVMatrix ) { - pmvMatrix.glPushMatrix(); + pmvMatrix.pushMv(); } else { - pmvMatrix.glLoadIdentity(); + pmvMatrix.loadMvIdentity(); } - pmvMatrix.glTranslatef(dx, dy, tz); + pmvMatrix.translateMv(dx, dy, tz); if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { - pmvMatrix.glScalef(sxy, -1f*sxy, 1.0f); + pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f); } else { - pmvMatrix.glScalef(sxy, sxy, 1.0f); + pmvMatrix.scaleMv(sxy, sxy, 1.0f); } renderer.enable(gl, true); region.draw(gl, renderer, vbaaSampleCount); renderer.enable(gl, false); if( !exclusivePMVMatrix ) { - pmvMatrix.glPopMatrix(); + pmvMatrix.popMv(); } } } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java index de4d616ba..c045342a1 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java @@ -51,6 +51,8 @@ import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.GlyphShape; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.Vec2i; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -67,8 +69,6 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.Vec2i; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; /** diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java index d515896b8..f22177a18 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java @@ -37,9 +37,18 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; import com.jogamp.graph.ui.shapes.CrossHair; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec2i; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -52,17 +61,7 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec2i; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Graph + GraphUI integration demo @@ -238,20 +237,19 @@ public class UIGraphDemoU01a { shape.setScale(s, s, 1f); } } - private void setMatrix(final PMVMatrix pmv, final Recti viewport) { - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); + private void setMatrix(final PMVMatrix4f pmv, final Recti viewport) { + pmv.loadPIdentity(); final float ratio = (float)viewport.width()/(float)viewport.height(); if( projOrthoWin ) { worldDim.setX( viewport.width() ); worldDim.setY( worldDim.x() / ratio ); // adjust aspect ratio - pmv.glOrthof(0, worldDim.x(), 0, worldDim.y(), zNear, zFar); + pmv.orthoP(0, worldDim.x(), 0, worldDim.y(), zNear, zFar); // similar: renderer.reshapeOrtho(viewport.width(), viewport.height(), zNear, zFar); } else if( projOrtho ) { worldDim.setY( worldDim.x() / ratio ); // adjust aspect ratio - pmv.glOrthof(-worldDim.x()/2f, worldDim.x()/2f, -worldDim.y()/2f, worldDim.y()/2f, zNear, zFar); + pmv.orthoP(-worldDim.x()/2f, worldDim.x()/2f, -worldDim.y()/2f, worldDim.y()/2f, zNear, zFar); } else { - pmv.gluPerspective(angle, ratio, zNear, zFar); + pmv.perspectiveP(angle, ratio, zNear, zFar); { final Vec3f obj00Coord = new Vec3f(); final Vec3f obj11Coord = new Vec3f(); @@ -264,15 +262,14 @@ public class UIGraphDemoU01a { worldDim.set(planeBox.getWidth(), planeBox.getHeight()); } } - pmv.glTranslatef(0f, 0f, sceneDist); // nose to plane + pmv.translateP(0f, 0f, sceneDist); // nose to plane - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + pmv.loadMvIdentity(); winToPlaneCoord(pmv, viewport, zNear, zFar, winOrigin.x(), winOrigin.y(), -sceneDist, worldOrigin); { - final Matrix4f p = pmv.getPMat(); - final Matrix4f mv = pmv.getMvMat(); + final Matrix4f p = pmv.getP(); + final Matrix4f mv = pmv.getMv(); System.err.println("Reshape VP: "+viewport); System.err.println("Reshape P :"); System.err.println(p.toString()); System.err.println("Reshape Mv:"); System.err.println(mv.toString()); @@ -280,14 +277,14 @@ public class UIGraphDemoU01a { System.err.println("Window Origin: "+winOrigin); System.err.println("World Origin : "+worldOrigin); } - pmv.glTranslatef(worldOrigin.x(), worldOrigin.y(), 0); // move to custom origin + pmv.translateMv(worldOrigin.x(), worldOrigin.y(), 0); // move to custom origin } - public static void winToPlaneCoord(final PMVMatrix pmv, final Recti viewport, + public static void winToPlaneCoord(final PMVMatrix4f pmv, final Recti viewport, final float zNear, final float zFar, final float winX, final float winY, final float objOrthoZ, final Vec3f objPos) { final float winZ = FloatUtil.getOrthoWinZ(objOrthoZ, zNear, zFar); - pmv.gluUnProject(winX, winY, winZ, viewport, objPos); + pmv.mapWinToObj(winX, winY, winZ, viewport, objPos); } @Override @@ -297,30 +294,29 @@ public class UIGraphDemoU01a { gl.glClearColor(1f, 1f, 1f, 1f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmv = renderer.getMatrix(); if( onceAtDisplay ) { - final Matrix4f p = pmv.getPMat(); - final Matrix4f mv = pmv.getMvMat(); + final Matrix4f p = pmv.getP(); + final Matrix4f mv = pmv.getMv(); System.err.println("Display.0: P :"); System.err.println(p.toString()); System.err.println("Display.0: Mv:"); System.err.println(mv.toString()); } renderer.enable(gl, true); { - pmv.glPushMatrix(); + pmv.pushMv(); drawText(gl, pmv, " Hello JogAmp Users!"); - pmv.glPopMatrix(); + pmv.popMv(); } if( !textOnly ) { - pmv.glPushMatrix(); - shape.setTransform(pmv); + pmv.pushMv(); + shape.setMvTransform(pmv); shape.draw(gl, renderer, sampleCount); if( onceAtDisplay ) { - final Matrix4f p = pmv.getPMat(); - final Matrix4f mv = pmv.getMvMat(); + final Matrix4f p = pmv.getP(); + final Matrix4f mv = pmv.getMv(); System.err.println("Display.1: P :"); System.err.println(p.toString()); System.err.println("Display.1: Mv:"); System.err.println(mv.toString()); System.err.println("Display.1: Shape bounds "+shape.getBounds(drawable.getGLProfile())); @@ -328,12 +324,12 @@ public class UIGraphDemoU01a { final Recti shapePort = shape.getSurfacePort(pmv, renderer.getViewport(), new Recti()); System.err.println("Display.1: Shape SurfacePort "+shapePort); } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); onceAtDisplay = false; } - private void drawText(final GL2ES2 gl, final PMVMatrix pmv, final String text) { + private void drawText(final GL2ES2 gl, final PMVMatrix4f pmv, final String text) { final AffineTransform tempT1 = new AffineTransform(); final AffineTransform tempT2 = new AffineTransform(); @@ -341,8 +337,8 @@ public class UIGraphDemoU01a { final float full_width_s = worldDim.x() / txt_box_em.getWidth(); final float full_height_s = worldDim.y() / txt_box_em.getHeight(); final float txt_scale = full_width_s < full_height_s ? full_width_s * normWidgetSize : full_height_s * normWidgetSize; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, textRegion.clear(gl), renderer, font, text, text_color, sampleCount, tempT1, tempT2); if( onceAtDisplay ) { @@ -351,7 +347,7 @@ public class UIGraphDemoU01a { System.err.println("XXX: txt_scale: "+txt_scale); System.err.println("XXX: txt_box_em "+txt_box_em); System.err.println("XXX: txt_box_r "+txt_box_r); - final AABBox textPort = txt_box_r.mapToWindow(new AABBox(), pmv.getPMvMat(), renderer.getViewport(), true /* useCenterZ */); + final AABBox textPort = txt_box_r.mapToWindow(new AABBox(), pmv.getPMv(), renderer.getViewport(), true /* useCenterZ */); System.err.println("Display.1: Shape TextPort "+textPort); final Font.GlyphVisitor visitor = new Font.GlyphVisitor() { diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java index 1da3ec886..396e5b07b 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java @@ -35,7 +35,6 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; @@ -45,6 +44,11 @@ import com.jogamp.graph.ui.layout.Margin; import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.graph.ui.shapes.BaseButton; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; @@ -56,10 +60,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; /** diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java index 2e97c839a..ac2663c43 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java @@ -33,7 +33,6 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; @@ -43,6 +42,11 @@ import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -52,10 +56,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; /** diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java index 08e5ba7fd..9ab65d3d7 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java @@ -37,6 +37,9 @@ import com.jogamp.graph.font.FontSet; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -44,11 +47,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement within one main function. @@ -125,7 +124,7 @@ public class UISceneDemo00 { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - shape.getScaledWidth(); - final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = shape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -172,7 +171,7 @@ public class UISceneDemo00 { static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height. @@ -181,9 +180,7 @@ public class UISceneDemo00 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy, sxy, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy, sxy, 1f); } }; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java index 83092d366..3f0bbce1c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java @@ -36,8 +36,10 @@ import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; -import com.jogamp.graph.ui.Scene.PMVMatrixSetup; import com.jogamp.graph.ui.shapes.GLButton; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -47,11 +49,7 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.es2.GearsES2; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement. @@ -133,7 +131,7 @@ public class UISceneDemo01 { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - shape.getScaledWidth(); - final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = shape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -180,7 +178,7 @@ public class UISceneDemo01 { static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 100 for the greater of width and height. @@ -189,9 +187,7 @@ public class UISceneDemo01 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy / 100f, sxy / 100f, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy / 100f, sxy / 100f, 1f); } }; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java index 10803e256..c6e09fa5c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java @@ -38,6 +38,9 @@ import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.GLButton; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -46,10 +49,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement. @@ -134,7 +134,7 @@ public class UISceneDemo01b { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - shape.getScaledWidth(); - final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = shape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -173,8 +173,8 @@ public class UISceneDemo01b { shape.getRotation().rotateByAngleY(rad); } System.err.println("Shape "+shape); - final PMVMatrix pmv = new PMVMatrix(); - shape.setTransform(pmv); + final PMVMatrix4f pmv = new PMVMatrix4f(); + shape.setMvTransform(pmv); System.err.println("Shape "+pmv); } } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java index f2fe509b2..3e5ee2171 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java @@ -36,6 +36,8 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -46,9 +48,7 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement. @@ -210,7 +210,7 @@ public class UISceneDemo02 { final float end_pos = sceneBox.getMinX() + ( destText.getText().length() == 0 ? 0 : destText.getScaledWidth() ); movingGlyph.moveTo(start_pos, 0f, 0f); - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final int[] destTextSizePx = destText.getSurfaceSize(scene, pmv, new int[2]); // [px] final int[] movingGlyphSizePx = movingGlyph.getSurfaceSize(scene, pmv, new int[2]); // [px] final float[] movingGlyphPixPerShapeUnit = movingGlyph.getPixelPerShapeUnit(movingGlyphSizePx, new float[2]); // [px]/[shapeUnit] diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java index b288ddb48..4a42209ae 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java @@ -50,6 +50,11 @@ import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -69,11 +74,6 @@ import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java index 6f720cb3e..f1bdb1e08 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java @@ -43,6 +43,10 @@ import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.CrossHair; import com.jogamp.graph.ui.shapes.GLButton; import com.jogamp.graph.ui.shapes.MediaButton; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -56,12 +60,7 @@ import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.es2.GearsES2; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; @@ -202,7 +201,7 @@ public class UISceneDemo10 { } static void testProject(final Scene scene, final Shape shape, final int glWinX, final int glWinY) { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final Vec3f objPos = shape.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, new Vec3f()); System.err.printf("MM1: winToObjCoord: obj %s%n", objPos); final int[] glWinPos = shape.shapeToWinCoord(scene.getPMVMatrixSetup(), scene.getViewport(), objPos, pmv, new int[2]); @@ -268,7 +267,7 @@ public class UISceneDemo10 { } static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height. @@ -277,9 +276,7 @@ public class UISceneDemo10 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy, sxy, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy, sxy, 1f); } }; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java index 120ab6203..140ce2e3a 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java @@ -41,6 +41,9 @@ import com.jogamp.graph.ui.layout.Alignment; import com.jogamp.graph.ui.layout.Gap; import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.shapes.Button; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -48,11 +51,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent {@link Shape}s in a {@link Group} using a {@link GridLayout}, contained within a Scene attached to GLWindow. @@ -158,7 +157,7 @@ public class UISceneDemo11 { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - mobileShape.getScaledWidth(); - final int[] shapeSizePx = mobileShape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = mobileShape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = mobileShape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -208,7 +207,7 @@ public class UISceneDemo11 { } static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height. @@ -217,9 +216,7 @@ public class UISceneDemo11 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy, sxy, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy, sxy, 1f); } }; } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java index 6204cd501..837d5770d 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java @@ -56,6 +56,10 @@ import com.jogamp.graph.ui.shapes.GLButton; import com.jogamp.graph.ui.shapes.ImageButton; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.MediaButton; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.ui.shapes.BaseButton; import com.jogamp.nativewindow.ScalableSurface; import com.jogamp.newt.Display; @@ -85,11 +89,7 @@ import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.graph.MSAATool; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayer.EventMask; import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; @@ -435,7 +435,7 @@ public class UISceneDemo20 implements GLEventListener { final com.jogamp.openal.sound3d.Source aSource) { AABBox worldBounds; { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); worldBounds = scene.getBounds(pmv, shape); } context.makeCurrent(true); @@ -793,7 +793,7 @@ public class UISceneDemo20 implements GLEventListener { if( e.getPointerCount() == 1 ) { final AABBox worldBounds; { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); worldBounds = scene.getBounds(pmv, shapeEvent.shape); } actionText = String.format((Locale)null, "Pos %s", worldBounds.getCenter()); @@ -1168,7 +1168,7 @@ public class UISceneDemo20 implements GLEventListener { if( e.getPointerCount() == 1 ) { final AABBox worldBounds; { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); worldBounds = scene.getBounds(pmv, shapeEvent.shape); } actionText = String.format((Locale)null, "Pos %s", worldBounds.getCenter()); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java index cc918c9fe..e34e2dec7 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java @@ -42,12 +42,6 @@ import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.demos.graph.MSAATool; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -55,10 +49,16 @@ import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.CrossHair; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -70,7 +70,6 @@ import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * Basic UIShape and Type Rendering demo. @@ -224,10 +223,9 @@ public class UIShapeDemo01 implements GLEventListener { rRenderer.reshapePerspective(FloatUtil.QUARTER_PI, width, height, zNear, zFar); // rRenderer.reshapeOrtho(width, height, zNear, zFar); - final PMVMatrix pmv = rRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = rRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); if( drawable instanceof Window ) { ((Window)drawable).setTitle(UIShapeDemo01.class.getSimpleName()+": "+drawable.getSurfaceWidth()+" x "+drawable.getSurfaceHeight()); @@ -237,9 +235,9 @@ public class UIShapeDemo01 implements GLEventListener { final int[] sampleCount = { 4 }; private void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final Shape shape) { - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glPushMatrix(); - shape.setTransform(pmv); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.pushMv(); + shape.setMvTransform(pmv); shape.draw(gl, renderer, sampleCount); if( once ) { System.err.println("draw.0: "+shape); @@ -248,7 +246,7 @@ public class UIShapeDemo01 implements GLEventListener { final int[] winPos = shape.shapeToWinCoord(pmv, renderer.getViewport(), shape.getPosition(), new int[2]); System.err.println("draw.2: winCoord "+winPos[0]+" x "+winPos[1]); } - pmv.glPopMatrix(); + pmv.popMv(); } @Override @@ -259,7 +257,7 @@ public class UIShapeDemo01 implements GLEventListener { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); + final PMVMatrix4f pmv = renderer.getMatrix(); renderer.enable(gl, true); drawShape(gl, renderer, button); drawShape(gl, renderer, crossHair); @@ -273,14 +271,14 @@ public class UIShapeDemo01 implements GLEventListener { final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar); final Vec3f objCoord0 = new Vec3f(); final Vec3f objCoord1 = new Vec3f(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord0); } } glWinX = drawable.getSurfaceWidth(); glWinY = drawable.getSurfaceHeight(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1); } @@ -290,9 +288,9 @@ public class UIShapeDemo01 implements GLEventListener { final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2); final float full_width_s = full_width_o / txt_box_em.getWidth(); final float txt_scale = full_width_s/2f; - pmv.glPushMatrix(); - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.pushMv(); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, new Vec4f( 0, 0, 0, 1 ), sampleCount, tempT1, tempT2); if( once ) { final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); @@ -302,7 +300,7 @@ public class UIShapeDemo01 implements GLEventListener { System.err.println("XXX: txt_box_rg "+txt_box_r); once = false; } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); } @@ -384,10 +382,9 @@ public class UIShapeDemo01 implements GLEventListener { System.err.println("\n\nMouse: "+e); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); // flip to GL window coordinates, origin bottom-left final Recti viewport = renderer.getViewport(new Recti()); @@ -395,8 +392,8 @@ public class UIShapeDemo01 implements GLEventListener { final int glWinY = viewport.height() - e.getY() - 1; { - pmv.glPushMatrix(); - button.setTransform(pmv); + pmv.pushMv(); + button.setMvTransform(pmv); System.err.println("\n\nButton: "+button); final Vec3f objPos = button.winToShapeCoord(pmv, viewport, glWinX, glWinY, new Vec3f()); @@ -409,11 +406,11 @@ public class UIShapeDemo01 implements GLEventListener { System.err.println("Button: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); } - pmv.glPopMatrix(); + pmv.popMv(); } { - pmv.glPushMatrix(); - crossHair.setTransform(pmv); + pmv.pushMv(); + crossHair.setMvTransform(pmv); final Vec3f objPosC = crossHair.getBounds().getCenter(); System.err.println("\n\nCrossHair: "+crossHair); @@ -439,7 +436,7 @@ public class UIShapeDemo01 implements GLEventListener { final int[] surfaceSize = crossHair.getSurfaceSize(pmv, viewport, new int[2]); System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - pmv.glPopMatrix(); + pmv.popMv(); } return true; } } ); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java index ecd7b1ccf..b89082d6d 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java @@ -39,10 +39,16 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.CrossHair; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -66,15 +72,8 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.demos.graph.MSAATool; import com.jogamp.opengl.demos.graph.ui.testshapes.Glyph03FreeMonoRegular_M; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * Basic UIShape and Type Rendering demo. @@ -257,11 +256,11 @@ public class UITypeDemo01 implements GLEventListener { final int[] sampleCount = { 4 }; - private void drawShape(final GL2ES2 gl, final PMVMatrix pmv, final RegionRenderer renderer, final Shape shape) { - pmv.glPushMatrix(); - shape.setTransform(pmv); + private void drawShape(final GL2ES2 gl, final PMVMatrix4f pmv, final RegionRenderer renderer, final Shape shape) { + pmv.pushMv(); + shape.setMvTransform(pmv); shape.draw(gl, renderer, sampleCount); - pmv.glPopMatrix(); + pmv.popMv(); } @Override @@ -272,16 +271,15 @@ public class UITypeDemo01 implements GLEventListener { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); renderer.enable(gl, true); { - pmv.glPushMatrix(); - pmv.glScalef(0.8f, 0.8f, 1f); + pmv.pushMv(); + pmv.scaleMv(0.8f, 0.8f, 1f); drawShape(gl, pmv, renderer, testObj); - pmv.glPopMatrix(); + pmv.popMv(); } drawShape(gl, pmv, renderer, crossHair); { @@ -294,14 +292,14 @@ public class UITypeDemo01 implements GLEventListener { final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar); final Vec3f objCoord0 = new Vec3f(); final Vec3f objCoord1 = new Vec3f(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord0); } } glWinX = drawable.getSurfaceWidth(); glWinY = drawable.getSurfaceHeight(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1); } @@ -309,7 +307,7 @@ public class UITypeDemo01 implements GLEventListener { full_width_o = objCoord1.x() - objCoord0.x(); full_height_o = objCoord1.y() - objCoord0.y(); } - pmv.glPushMatrix(); + pmv.pushMv(); final Font.Glyph glyph; if( Glyph.ID_UNKNOWN < glyph_id ) { @@ -325,8 +323,8 @@ public class UITypeDemo01 implements GLEventListener { final float full_width_s = full_width_o / txt_box_em.getWidth(); final float full_height_s = full_height_o / txt_box_em.getHeight(); final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); if( null != glyph.getShape() ) { final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null, glyph.getShape()); region.addOutlineShape(glyph.getShape(), null, fg_color); @@ -346,8 +344,8 @@ public class UITypeDemo01 implements GLEventListener { final float full_width_s = full_width_o / txt_box_em.getWidth(); final float full_height_s = full_height_o / txt_box_em.getHeight(); final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, fg_color, sampleCount, tempT1, tempT2); if( once ) { final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); @@ -359,7 +357,7 @@ public class UITypeDemo01 implements GLEventListener { System.err.println("XXX: txt_box_rg "+txt_box_r); } } - pmv.glPopMatrix(); + pmv.popMv(); if( once ) { try { printScreen(drawable); @@ -454,10 +452,9 @@ public class UITypeDemo01 implements GLEventListener { System.err.println("\n\nMouse: "+e); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); // flip to GL window coordinates, origin bottom-left final Recti viewport = renderer.getViewport(new Recti()); @@ -465,8 +462,8 @@ public class UITypeDemo01 implements GLEventListener { final int glWinY = viewport.height() - e.getY() - 1; { - pmv.glPushMatrix(); - crossHair.setTransform(pmv); + pmv.pushMv(); + crossHair.setMvTransform(pmv); final Vec3f objPosC = crossHair.getBounds().getCenter(); System.err.println("\n\nCrossHair: "+crossHair); @@ -493,7 +490,7 @@ public class UITypeDemo01 implements GLEventListener { final int[] surfaceSize = crossHair.getSurfaceSize(pmv, viewport, new int[2]); System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - pmv.glPopMatrix(); + pmv.popMv(); } return true; } } ); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java b/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java index 5af14cb45..9b8b8cbdb 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java @@ -28,8 +28,8 @@ package com.jogamp.opengl.demos.graph.ui.testshapes; import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.geom.plane.Winding; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.math.geom.plane.Winding; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java b/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java index aaf1bba20..08fa684f4 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java @@ -33,10 +33,10 @@ import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.texture.TextureSequence; public class Tooltips { |