Skip to content

Commit 20ff5c9

Browse files
committed
applied last changes from java
1 parent 5af9cf8 commit 20ff5c9

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4469,7 +4469,7 @@ protected void defaultCamera() {
44694469
*/
44704470
@Override
44714471
public void ortho() {
4472-
ortho(0, width, 0, height, cameraNear, cameraFar);
4472+
ortho(0, width, 0, height, 0, cameraEyeZ * 10);
44734473
}
44744474

44754475

@@ -4480,7 +4480,7 @@ public void ortho() {
44804480
@Override
44814481
public void ortho(float left, float right,
44824482
float bottom, float top) {
4483-
ortho(left, right, bottom, top, cameraNear, cameraFar);
4483+
ortho(left, right, bottom, top, 0, cameraEyeZ * 10);
44844484
}
44854485

44864486

@@ -4492,24 +4492,27 @@ public void ortho(float left, float right,
44924492
public void ortho(float left, float right,
44934493
float bottom, float top,
44944494
float near, float far) {
4495-
// Translating the origin to (widht/2, height/2) since the matrix math
4496-
// below assumes the center of the screen to be (0, 0), but in Processing
4497-
// it is (w/2, h/2).
4498-
left -= width/2f;
4499-
right -= width/2f;
4500-
bottom -= height/2f;
4501-
top -= height/2f;
4495+
float w = right - left;
4496+
float h = top - bottom;
4497+
float d = far - near;
4498+
4499+
// Applying the camera translation (only on x and y, as near and far
4500+
// are given as distances from the viewer)
4501+
left -= cameraEyeX;
4502+
right -= cameraEyeX;
4503+
bottom -= cameraEyeY;
4504+
top -= cameraEyeY;
45024505

45034506
// Flushing geometry with a different perspective configuration.
45044507
flush();
45054508

4506-
float x = +2.0f / (right - left);
4507-
float y = +2.0f / (top - bottom);
4508-
float z = -2.0f / (far - near);
4509+
float x = +2.0f / w;
4510+
float y = +2.0f / h;
4511+
float z = -2.0f / d;
45094512

4510-
float tx = -(right + left) / (right - left);
4511-
float ty = -(top + bottom) / (top - bottom);
4512-
float tz = -(far + near) / (far - near);
4513+
float tx = -(right + left) / w;
4514+
float ty = -(top + bottom) / h;
4515+
float tz = -(far + near) / d;
45134516

45144517
// The minus sign is needed to invert the Y axis.
45154518
projection.set(x, 0, 0, tx,

0 commit comments

Comments
 (0)