Skip to content

Commit f97a0f8

Browse files
committed
added shift in ortho() so the default 2D projection is ortho(0, width, height, 0,...), as with glOrtho()
1 parent ba73023 commit f97a0f8

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
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(0, width, height, 0, -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(0, width, height, 0, -1, +1);
8989
pushMatrix();
9090
camera(width/2, height/2);
9191
}

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 7 additions & 22 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(0, width, height, 0, cameraNear, cameraFar);
40584058
}
40594059

40604060

@@ -4070,33 +4070,18 @@ public void ortho(float left, float right,
40704070

40714071

40724072
/**
4073-
* Sets an orthographic projection. The left, right, bottom and top
4074-
* values refer to the center of the screen, with the y-axis inverted
4075-
* with respect to the default orientation in Processing, e.g: botton-to-top
4076-
* instead of top-to-bottom.
4077-
* In particular, if we need to set the the orthographic projection exactly
4078-
* covering the rectangle starting at the origin and having the same
4079-
* dimensions as the screen size, then we would pass:
4080-
* left = -width/2
4081-
* right = +width/2
4082-
* bottom = +height/2
4083-
* top = -height/2
4084-
* In general, if we want to set an ortographic projection covering the
4085-
* rectangle determined by the top-left corner (x0, y0) and bottom-right
4086-
* corner (x1, y1), we would need to pass the following parameters:
4087-
* left = x0 - width/2
4088-
* right = x1 - width/2
4089-
* bottom = height/2 - y0
4090-
* top = height/2 - y1
4091-
* that just correspond to the change of coordinates between the
4092-
* coordinate system located at the screen center with the Y-axis
4093-
* bottom-to-top, and Processing's system.
4073+
* Sets an orthographic projection.
40944074
*
40954075
*/
40964076
@Override
40974077
public void ortho(float left, float right,
40984078
float bottom, float top,
40994079
float near, float far) {
4080+
left -= width/2;
4081+
right -= width/2;
4082+
bottom -= height/2;
4083+
top -= height/2;
4084+
41004085
// Flushing geometry with a different perspective configuration.
41014086
flush();
41024087

0 commit comments

Comments
 (0)