summaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-07 08:46:18 +0200
committerSven Gothel <[email protected]>2023-04-07 08:46:18 +0200
commit84a6d63205ec49ddfb36b57fe2888425ecda3a5a (patch)
tree354cec2ac14a8932a01122c5234926e774ef874e /src/demos/com/jogamp/opengl
parent10b60e10ece3cbc3e0b8a68ac73229371530e0ba (diff)
PMVMatrix rewrite using Matrix4f, providing SyncMatrix4f* for GLUniformData; Utilize Vec3f, Recti, .. throughout API (Matrix4f, AABBox, .. Graph*)
Big Easter Cleanup - Net -214 lines of code, despite new classes. - GLUniformData buffer can be synced w/ underlying data via SyncAction/SyncBuffer, e.g. SyncMatrix4f + SyncMatrices4f - PMVMatrix rewrite using Matrix4f and providing SyncMatrix4f/Matrices4f to sync w/ GLUniformData - Additional SyncMatrix4f16 + SyncMatrices4f16 covering Matrix4f sync w/ GLUniformData w/o PMVMatrix - Utilize Vec3f, Recti, .. throughout API (Matrix4f, AABBox, .. Graph*) - Moved FloatUtil -> Matrix4f, kept a few basic matrix ops for ProjectFloat - Most, if not all, float[] and int[] should have been moved to proper classes - int[] -> Recti for viewport rectangle - Matrix4f and PMVMatrix is covered by math unit tests (as was FloatUtil before) -> save Passed all unit tests on AMD64 GNU/Linux
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r--src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java19
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/GearsES2.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java8
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java20
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java29
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java11
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java11
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java9
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java11
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java19
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java21
14 files changed, 89 insertions, 77 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java
index 3a0955a05..5fd70f97c 100644
--- a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java
+++ b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java
@@ -63,6 +63,7 @@ import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.demos.graph.TextRendererGLELBase;
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;
@@ -465,10 +466,10 @@ public class MovieSBSStereo implements StereoGLEventListener {
// Push the 1st uniform down the path
st.useProgram(gl, true);
- final int[] viewPort = new int[] { 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()};
+ final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
pmvMatrix = new PMVMatrix();
- reshapePMV(viewPort[2], viewPort[3]);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ reshapePMV(viewPort.width(), viewPort.height());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
@@ -494,12 +495,12 @@ public class MovieSBSStereo implements StereoGLEventListener {
{
System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]);
System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]);
- final float[] winLB = new float[3];
- final float[] winRT = new float[3];
- pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0);
- pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0);
- System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]);
- System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]);
+ 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);
+ System.err.println("XXX0: win LB: "+winLB);
+ System.err.println("XXX0: win RT: "+winRT);
}
interleavedVBOLeft = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
index 5ad6ede76..76ee32301 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java
@@ -233,7 +233,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
pmvMatrix = new PMVMatrix();
st.attachObject("pmvMatrix", pmvMatrix);
- pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit
+ pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMvitMat()); // 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 0b4dac9b2..68152ad58 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java
@@ -68,10 +68,12 @@ public class PointsDemoES2 extends PointsDemo {
this.swapInterval = 1;
}
+ @Override
public void setSmoothPoints(final boolean v) {
pointParams.put(1, v ? 1.0f : 0.0f);
}
+ @Override
public void setPointParams(final float minSize, final float maxSize, final float distAttenConst, final float distAttenLinear, final float distAttenQuadratic, final float fadeThreshold) {
pointParams.put(2, minSize);
pointParams.put(3, maxSize);
@@ -81,6 +83,7 @@ public class PointsDemoES2 extends PointsDemo {
pointParams.put(4+3, fadeThreshold);
}
+ @Override
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -109,7 +112,7 @@ public class PointsDemoES2 extends PointsDemo {
pmvMatrix.glLoadIdentity();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
@@ -144,6 +147,7 @@ public class PointsDemoES2 extends PointsDemo {
st.useProgram(gl, false);
}
+ @Override
public void display(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
gl.glClearColor(0f, 0f, 0f, 0f);
@@ -183,6 +187,7 @@ public class PointsDemoES2 extends PointsDemo {
st.useProgram(gl, false);
}
+ @Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
// Thread.dumpStack();
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -199,6 +204,7 @@ public class PointsDemoES2 extends PointsDemo {
st.useProgram(gl, false);
}
+ @Override
public void dispose(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
st.destroy(gl);
diff --git a/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java b/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java
index a6e1f5cd9..da8235c8f 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.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // 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 211ac8cbf..e9a2ad66d 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java
@@ -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.glGetPMvMatrixf()); // P, Mv
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // 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 2814313c5..c556f2a2f 100644
--- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java
+++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java
@@ -40,6 +40,8 @@ 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.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;
@@ -163,10 +165,10 @@ public class TextureSequenceES2 implements GLEventListener {
// Push the 1st uniform down the path
st.useProgram(gl, true);
- final int[] viewPort = new int[] { 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()};
+ final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
pmvMatrix = new PMVMatrix();
- reshapePMV(viewPort[2], viewPort[3]);
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ reshapePMV(viewPort.width(), viewPort.height());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat());
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
@@ -200,12 +202,12 @@ public class TextureSequenceES2 implements GLEventListener {
{
System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]);
System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]);
- final float[] winLB = new float[3];
- final float[] winRT = new float[3];
- pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0);
- pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0);
- System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]);
- System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]);
+ 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);
+ System.err.println("XXX0: win LB: "+winLB);
+ System.err.println("XXX0: win RT: "+winRT);
}
interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java
index 5bceba5eb..d02764cc0 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java
@@ -50,6 +50,8 @@ 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.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;
@@ -146,12 +148,12 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
getRenderer().init(gl);
}
- public static void mapWin2ObjectCoords(final PMVMatrix pmv, final int[] view,
+ public static void mapWin2ObjectCoords(final PMVMatrix pmv, final Recti view,
final float zNear, final float zFar,
final float orthoX, final float orthoY, final float orthoDist,
- final float[] winZ, final float[] objPos) {
+ final float[] winZ, final Vec3f objPos) {
winZ[0] = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar);
- pmv.gluUnProject(orthoX, orthoY, winZ[0], view, 0, objPos, 0);
+ pmv.gluUnProject(orthoX, orthoY, winZ[0], view, objPos);
}
@Override
@@ -161,26 +163,21 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
System.err.printf("Reshape: zNear %f, zFar %f%n", zNear, zFar);
- System.err.printf("Reshape: Frustum: %s%n", pmv.glGetFrustum());
+ System.err.printf("Reshape: Frustum: %s%n", pmv.getFrustum());
{
final float orthoDist = 1f;
- final float[] obj00Coord = new float[3];
- final float[] obj11Coord = new float[3];
+ final Vec3f obj00Coord = new Vec3f();
+ final Vec3f obj11Coord = new Vec3f();
final float[] winZ = new float[1];
- final int[] view = new int[] { 0, 0, width, height };
+ final Recti view = new Recti(0, 0, width, height);
mapWin2ObjectCoords(pmv, view, zNear, zFar, 0f, 0f, orthoDist, winZ, obj00Coord);
- System.err.printf("Reshape: mapped.00: [%f, %f, %f], winZ %f -> [%f, %f, %f]%n", 0f, 0f, orthoDist, winZ[0], obj00Coord[0], obj00Coord[1], obj00Coord[2]);
+ System.err.printf("Reshape: mapped.00: [%f, %f, %f], winZ %f -> [%s]%n", 0f, 0f, orthoDist, winZ[0], obj00Coord);
mapWin2ObjectCoords(pmv, view, zNear, zFar, width, height, orthoDist, winZ, obj11Coord);
- System.err.printf("Reshape: mapped.11: [%f, %f, %f], winZ %f -> [%f, %f, %f]%n", (float)width, (float)height, orthoDist, winZ[0], obj11Coord[0], obj11Coord[1], obj11Coord[2]);
-
- nearPlane1Box.setSize( obj00Coord[0], // lx
- obj00Coord[1], // ly
- obj00Coord[2], // lz
- obj11Coord[0], // hx
- obj11Coord[1], // hy
- obj11Coord[2] );// hz
+ System.err.printf("Reshape: mapped.11: [%f, %f, %f], winZ %f -> [%s]%n", (float)width, (float)height, orthoDist, winZ[0], obj11Coord);
+
+ nearPlane1Box.setSize( obj00Coord, obj11Coord );
System.err.printf("Reshape: dist1Box: %s%n", nearPlane1Box);
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java
index cab25b83d..9685f2cf9 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java
@@ -393,7 +393,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
rs.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f);
if( bottomTextUseFrustum ) {
- regionBottom.setFrustum(pmv.glGetFrustum());
+ regionBottom.setFrustum(pmv.getFrustum());
}
if(!userInput) {
if( bottomTextUseFrustum ) {
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 3bf506e8f..5c65f4c29 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -47,6 +47,7 @@ import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.es2.GearsES2;
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;
@@ -184,8 +185,8 @@ public class UISceneDemo01 {
static class MyPMVMatrixSetup implements PMVMatrixSetup {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float)width/(float)height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float)viewport.width()/(float)viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
@@ -196,7 +197,7 @@ public class UISceneDemo01 {
// Scale (back) to have normalized plane dimensions, 100 for the greater of width and height.
final AABBox planeBox0 = new AABBox();
- setPlaneBox(planeBox0, pmv, x, y, width, height);
+ setPlaneBox(planeBox0, pmv, viewport);
final float sx = planeBox0.getWidth();
final float sy = planeBox0.getHeight();
final float sxy = sx > sy ? sx : sy;
@@ -206,8 +207,8 @@ public class UISceneDemo01 {
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, x, y, width, height);
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
+ Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
}
};
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 7df78ca99..06631fdb2 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -56,6 +56,7 @@ import com.jogamp.opengl.demos.util.MiscUtils;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
+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;
@@ -199,7 +200,7 @@ public class UISceneDemo03 {
final GLProfile hasGLP = window.getChosenGLCapabilities().getGLProfile();
final AABBox sceneBox = scene.getBounds();
System.err.println("SceneBox " + sceneBox);
- System.err.println("Frustum " + scene.getMatrix().glGetFrustum());
+ System.err.println("Frustum " + scene.getMatrix().getFrustum());
final Label statusLabel;
{
@@ -421,8 +422,8 @@ public class UISceneDemo03 {
*/
public static class MyPMVMatrixSetup implements PMVMatrixSetup {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float) width / (float) height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float) viewport.width() / (float) viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
@@ -433,8 +434,8 @@ public class UISceneDemo03 {
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, x, y, width, height);
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
+ Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
}
};
}
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 0874df04e..0345515fc 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
@@ -56,6 +56,7 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.es2.GearsES2;
import com.jogamp.opengl.demos.util.MiscUtils;
+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;
@@ -157,18 +158,18 @@ public class UISceneDemo10 {
shape.addMouseListener(new Shape.MouseGestureAdapter() {
@Override
public void mouseMoved(final MouseEvent e) {
- final int[] viewport = scene.getViewport(new int[4]);
+ final Recti viewport = scene.getViewport(new Recti());
// flip to GL window coordinates, origin bottom-left
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
testProject(scene, shape, glWinX, glWinY);
}
@Override
public void mouseDragged(final MouseEvent e) {
- final int[] viewport = scene.getViewport(new int[4]);
+ final Recti viewport = scene.getViewport(new Recti());
// flip to GL window coordinates, origin bottom-left
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
testProject(scene, shape, glWinX, glWinY);
}
} );
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 5e94758dc..f181e51b9 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -80,6 +80,7 @@ import com.jogamp.opengl.demos.graph.MSAATool;
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.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -991,8 +992,8 @@ public class UISceneDemo20 implements GLEventListener {
*/
public static class MyPMVMatrixSetup implements PMVMatrixSetup {
@Override
- public void set(final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- final float ratio = (float)width/(float)height;
+ public void set(final PMVMatrix pmv, final Recti viewport) {
+ final float ratio = (float)viewport.width()/(float)viewport.height();
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glLoadIdentity();
pmv.gluPerspective(Scene.DEFAULT_ANGLE, ratio, Scene.DEFAULT_ZNEAR, Scene.DEFAULT_ZFAR);
@@ -1003,15 +1004,15 @@ public class UISceneDemo20 implements GLEventListener {
// Translate origin to bottom-left
final AABBox planeBox0 = new AABBox();
- setPlaneBox(planeBox0, pmv, x, y, width, height);
+ setPlaneBox(planeBox0, pmv, viewport);
pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmv.glTranslatef(planeBox0.getMinX(), planeBox0.getMinY(), 0f);
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
}
@Override
- public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final int x, final int y, final int width, final int height) {
- Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, x, y, width, height);
+ public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) {
+ Scene.getDefaultPMVMatrixSetup().setPlaneBox(planeBox, pmv, viewport);
}
};
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 fc4b275de..8e2c45431 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
@@ -44,6 +44,7 @@ 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.geom.AABBox;
import com.jogamp.common.util.InterruptSource;
@@ -273,21 +274,21 @@ public class UIShapeDemo01 implements GLEventListener {
float glWinX = 0;
float glWinY = 0;
final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar);
- final float[] objCoord0 = new float[3];
- final float[] objCoord1 = new float[3];
- if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord0, 0) ) {
+ final Vec3f objCoord0 = new Vec3f();
+ final Vec3f objCoord1 = new Vec3f();
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]);
+ 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(), 0, objCoord1, 0) ) {
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]);
+ System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1);
}
}
- full_width_o = objCoord1[0] - objCoord0[0];
+ full_width_o = objCoord1.x() - objCoord0.x();
}
final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2);
final float full_width_s = full_width_o / txt_box_em.getWidth();
@@ -392,9 +393,9 @@ public class UIShapeDemo01 implements GLEventListener {
pmv.glTranslatef(xTran, yTran, zTran);
// flip to GL window coordinates, origin bottom-left
- final int[] viewport = renderer.getViewport(new int[4]);
+ final Recti viewport = renderer.getViewport(new Recti());
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
{
pmv.glPushMatrix();
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 d4e7bfc0f..ed96112cd 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
@@ -68,6 +68,7 @@ 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.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -294,22 +295,22 @@ public class UITypeDemo01 implements GLEventListener {
float glWinX = 0;
float glWinY = 0;
final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar);
- final float[] objCoord0 = new float[3];
- final float[] objCoord1 = new float[3];
- if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord0, 0) ) {
+ final Vec3f objCoord0 = new Vec3f();
+ final Vec3f objCoord1 = new Vec3f();
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]);
+ 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(), 0, objCoord1, 0) ) {
+ if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) {
if( once ) {
- System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]);
+ System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1);
}
}
- full_width_o = objCoord1[0] - objCoord0[0];
- full_height_o = objCoord1[1] - objCoord0[1];
+ full_width_o = objCoord1.x() - objCoord0.x();
+ full_height_o = objCoord1.y() - objCoord0.y();
}
pmv.glPushMatrix();
@@ -462,9 +463,9 @@ public class UITypeDemo01 implements GLEventListener {
pmv.glTranslatef(xTran, yTran, zTran);
// flip to GL window coordinates, origin bottom-left
- final int[] viewport = renderer.getViewport(new int[4]);
+ final Recti viewport = renderer.getViewport(new Recti());
final int glWinX = e.getX();
- final int glWinY = viewport[3] - e.getY() - 1;
+ final int glWinY = viewport.height() - e.getY() - 1;
{
pmv.glPushMatrix();