ortho()
Lights Camera / CameraDescription
Sets an orthographic projection, where objects appear flat and no foreshortening occurs.
Syntax
void ortho()
void ortho(float left, float right, float bottom, float top, float near, float far)
Parameters
| Name | Type | Description |
|---|---|---|
| left | float | left clipping plane |
| right | float | right clipping plane |
| bottom | float | bottom clipping plane |
| top | float | top clipping plane |
| near | float | near clipping plane |
| far | float | far clipping plane |
Returns
voidRelated
Under the Hood
From Processing.h:
void ortho();
void ortho(float l, float r, float b, float t, float n, float f);
Under the Hood
From Processing.cpp:
void PApplet::ortho() {
// Default ortho: 1:1 pixel mapping, origin at top-left, Y increases downward.
// glOrtho(l, r, bottom, top, near, far):
// bottom = winHeight (screen bottom = large Y in Processing)
// top = 0 (screen top = Y=0 in Processing)
// gluLookAt is NOT used here -- we want raw screen-space coordinates,
// so we use a simple identity modelview with Y-flipped glOrtho.
glMatrixMode(GL_PROJECTION); glLoadIdentity();
glOrtho(0, logicalW, logicalH, 0, -logicalH, logicalH);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
glFrontFace(GL_CW);
glDisable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void PApplet::ortho(float l, float r, float b, float t, float n, float f) {
// Processing Java ortho() uses the SAME standard modelview as perspective()
// (eye at eyeZ above canvas center, looking at canvas center).
// Only the projection changes: orthographic instead of frustum.
// The Y-flip (glScalef 1,-1,1) is applied in projection space so that
// Processing's Y-down screen coordinate convention is preserved.
//
// With the standard camera, world point (w/2, h/2, 0) is at screen center.
// ortho(-w/2, w/2, -h/2, h/2) covers that range around the camera target.
// So translate(w/2, h/2) correctly lands at the center of the screen.
glMatrixMode(GL_PROJECTION); glLoadIdentity();
glScalef(1,-1,1); // Y-flip before ortho (Java order)
glOrtho(l, r, b, t, n, f);
applyStandardModelview();
}