mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
arguments in ortho() refer to screen center
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user