Skip to content

Commit 9765f5c

Browse files
committed
using processing Y-axis orientation for ortho() and frustum(), centering ortho() at top left corner.
1 parent f97a0f8 commit 9765f5c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

core/src/processing/opengl/PGraphics2D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void frustum(float left, float right, float bottom, float top,
120120

121121
@Override
122122
protected void defaultPerspective() {
123-
super.ortho(0, width, height, 0, -1, +1);
123+
super.ortho(0, width, 0, height, -1, +1);
124124
}
125125

126126

core/src/processing/opengl/PGraphics3D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected void defaultCamera() {
8585
@Override
8686
protected void begin2D() {
8787
pushProjection();
88-
ortho(0, width, height, 0, -1, +1);
88+
ortho(0, width, 0, height, -1, +1);
8989
pushMatrix();
9090
camera(width/2, height/2);
9191
}

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,7 @@ protected void defaultCamera() {
40544054
*/
40554055
@Override
40564056
public void ortho() {
4057-
ortho(0, width, height, 0, cameraNear, cameraFar);
4057+
ortho(0, width, 0, height, cameraNear, cameraFar);
40584058
}
40594059

40604060

@@ -4094,10 +4094,10 @@ public void ortho(float left, float right,
40944094
float tz = -(far + near) / (far - near);
40954095

40964096
// The minus sign is needed to invert the Y axis.
4097-
projection.set(x, 0, 0, tx,
4098-
0, y, 0, ty,
4099-
0, 0, z, tz,
4100-
0, 0, 0, 1);
4097+
projection.set(x, 0, 0, tx,
4098+
0, -y, 0, ty,
4099+
0, 0, z, tz,
4100+
0, 0, 0, 1);
41014101

41024102
calcProjmodelview();
41034103

@@ -4140,7 +4140,7 @@ public void perspective(float fov, float aspect, float zNear, float zFar) {
41404140
float ymin = -ymax;
41414141
float xmin = ymin * aspect;
41424142
float xmax = ymax * aspect;
4143-
frustum(xmin, xmax, ymax, ymin, zNear, zFar);
4143+
frustum(xmin, xmax, ymin, ymax, zNear, zFar);
41444144
}
41454145

41464146

@@ -4161,10 +4161,10 @@ public void frustum(float left, float right, float bottom, float top,
41614161
float h = top - bottom;
41624162
float d = zfar - znear;
41634163

4164-
projection.set(n2 / w, 0, (right + left) / w, 0,
4165-
0, n2 / h, (top + bottom) / h, 0,
4166-
0, 0, -(zfar + znear) / d, -(n2 * zfar) / d,
4167-
0, 0, -1, 0);
4164+
projection.set(n2 / w, 0, (right + left) / w, 0,
4165+
0, -n2 / h, (top + bottom) / h, 0,
4166+
0, 0, -(zfar + znear) / d, -(n2 * zfar) / d,
4167+
0, 0, -1, 0);
41684168

41694169
calcProjmodelview();
41704170

0 commit comments

Comments
 (0)