arguments in ortho() refer to screen center

This commit is contained in:
codeanticode
2012-05-25 17:32:09 +00:00
parent ce0efb24f6
commit 31c1e23c48
4 changed files with 3 additions and 15 deletions
@@ -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();
@@ -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);
@@ -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),
@@ -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);