Skip to content

Commit ba73023

Browse files
committed
Fixes axis-orientation inconsistency in ortho() and fustrum() (issue #1240)
1 parent 31387eb commit ba73023

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
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(-width/2, +width/2, -height/2, +height/2, -1, +1);
123+
super.ortho(-width/2, +width/2, +height/2, -height/2, -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(-width/2, +width/2, -height/2, +height/2, -1, +1);
88+
ortho(-width/2, +width/2, +height/2, -height/2, -1, +1);
8989
pushMatrix();
9090
camera(width/2, height/2);
9191
}

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 14 additions & 14 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(-width/2, +width/2, -height/2, +height/2, cameraNear, cameraFar);
4057+
ortho(-width/2, +width/2, +height/2, -height/2, cameraNear, cameraFar);
40584058
}
40594059

40604060

@@ -4079,15 +4079,15 @@ public void ortho(float left, float right,
40794079
* dimensions as the screen size, then we would pass:
40804080
* left = -width/2
40814081
* right = +width/2
4082-
* bottom = -height/2
4083-
* top = +height/2
4082+
* bottom = +height/2
4083+
* top = -height/2
40844084
* In general, if we want to set an ortographic projection covering the
40854085
* rectangle determined by the top-left corner (x0, y0) and bottom-right
40864086
* corner (x1, y1), we would need to pass the following parameters:
40874087
* left = x0 - width/2
40884088
* right = x1 - width/2
4089-
* bottom = height/2 - y1
4090-
* top = height/2 - y0
4089+
* bottom = height/2 - y0
4090+
* top = height/2 - y1
40914091
* that just correspond to the change of coordinates between the
40924092
* coordinate system located at the screen center with the Y-axis
40934093
* bottom-to-top, and Processing's system.
@@ -4109,10 +4109,10 @@ public void ortho(float left, float right,
41094109
float tz = -(far + near) / (far - near);
41104110

41114111
// The minus sign is needed to invert the Y axis.
4112-
projection.set(x, 0, 0, tx,
4113-
0, -y, 0, ty,
4114-
0, 0, z, tz,
4115-
0, 0, 0, 1);
4112+
projection.set(x, 0, 0, tx,
4113+
0, y, 0, ty,
4114+
0, 0, z, tz,
4115+
0, 0, 0, 1);
41164116

41174117
calcProjmodelview();
41184118

@@ -4155,7 +4155,7 @@ public void perspective(float fov, float aspect, float zNear, float zFar) {
41554155
float ymin = -ymax;
41564156
float xmin = ymin * aspect;
41574157
float xmax = ymax * aspect;
4158-
frustum(xmin, xmax, ymin, ymax, zNear, zFar);
4158+
frustum(xmin, xmax, ymax, ymin, zNear, zFar);
41594159
}
41604160

41614161

@@ -4176,10 +4176,10 @@ public void frustum(float left, float right, float bottom, float top,
41764176
float h = top - bottom;
41774177
float d = zfar - znear;
41784178

4179-
projection.set(n2 / w, 0, (right + left) / w, 0,
4180-
0, -n2 / h, (top + bottom) / h, 0,
4181-
0, 0, -(zfar + znear) / d, -(n2 * zfar) / d,
4182-
0, 0, -1, 0);
4179+
projection.set(n2 / w, 0, (right + left) / w, 0,
4180+
0, n2 / h, (top + bottom) / h, 0,
4181+
0, 0, -(zfar + znear) / d, -(n2 * zfar) / d,
4182+
0, 0, -1, 0);
41834183

41844184
calcProjmodelview();
41854185

0 commit comments

Comments
 (0)