From 31c1e23c48525ea65e744c6e4c8bb57544968214 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Fri, 25 May 2012 17:32:09 +0000 Subject: [PATCH] arguments in ortho() refer to screen center --- .../libraries/opengl/examples/Camera/NearFar/NearFar.pde | 2 +- .../Camera/OrthoVSPerspective/OrthoVSPerspective.pde | 2 +- .../opengl/examples/Lights/CameraLight/CameraLight.pde | 5 +---- .../opengl/src/processing/opengl/PGraphicsOpenGL.java | 9 --------- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/java/libraries/opengl/examples/Camera/NearFar/NearFar.pde b/java/libraries/opengl/examples/Camera/NearFar/NearFar.pde index 9403513ab..a80c4a37c 100644 --- a/java/libraries/opengl/examples/Camera/NearFar/NearFar.pde +++ b/java/libraries/opengl/examples/Camera/NearFar/NearFar.pde @@ -54,7 +54,7 @@ void draw() { if (usingPerspective) { perspective(cameraFOV, float(width)/float(height), cameraNear, cameraFar); } else { - ortho(0, width, 0, height, cameraNear, cameraFar); + ortho(-width/2, width/2, -height/2, height/2, cameraNear, cameraFar); } pushMatrix(); diff --git a/java/libraries/opengl/examples/Camera/OrthoVSPerspective/OrthoVSPerspective.pde b/java/libraries/opengl/examples/Camera/OrthoVSPerspective/OrthoVSPerspective.pde index fbb1c7721..02b7cec68 100755 --- a/java/libraries/opengl/examples/Camera/OrthoVSPerspective/OrthoVSPerspective.pde +++ b/java/libraries/opengl/examples/Camera/OrthoVSPerspective/OrthoVSPerspective.pde @@ -31,7 +31,7 @@ void draw() perspective(fov, float(width)/float(height), cameraZ/2.0, cameraZ*2.0); } else { - ortho(0, width, 0, height, -200, +200); + ortho(-width/2, width/2, -height/2, height/2, 0, 400); } translate(width/2, height/2, 0); diff --git a/java/libraries/opengl/examples/Lights/CameraLight/CameraLight.pde b/java/libraries/opengl/examples/Lights/CameraLight/CameraLight.pde index 551eb20b0..4d99aa00e 100755 --- a/java/libraries/opengl/examples/Lights/CameraLight/CameraLight.pde +++ b/java/libraries/opengl/examples/Lights/CameraLight/CameraLight.pde @@ -16,11 +16,8 @@ void draw() { lights(); if (mousePressed) { - // The arguments of ortho are specified in screen coordinates, where (0,0) - // is the upper left corner of the screen - ortho(0, width, 0, height); + ortho(-width/2, width/2, -height/2, height/2); } else { - float fov = PI/3.0; float cameraZ = (height/2.0) / tan(fov/2.0); perspective(fov, float(width)/float(height), diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index d6fbb4566..854112919 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -3873,15 +3873,6 @@ public class PGraphicsOpenGL extends PGraphics { float near, float far) { // Flushing geometry with a different perspective configuration. flush(); - - float halfw = 0.5f * (right - left); - float halfh = 0.5f * (top - bottom); - - left -= halfw; - right -= halfw; - - bottom -= halfh; - top -= halfh; float x = 2.0f / (right - left); float y = 2.0f / (top - bottom);