Title: ortho broken (again) - suggested simple fix · Issue #6175 · processing/processing · GitHub
Open Graph Title: ortho broken (again) - suggested simple fix · Issue #6175 · processing/processing
X Title: ortho broken (again) - suggested simple fix · Issue #6175 · processing/processing
Description: Description ortho is broken and doesn't work as expected. I found other bug reports on this but they were >7 years old so I'm reposting, a lot has changed since then. Expected Behavior ortho(0, width, 0, height), with a clear modelview m...
Open Graph Description: Description ortho is broken and doesn't work as expected. I found other bug reports on this but they were >7 years old so I'm reposting, a lot has changed since then. Expected Behavior ortho(0, wid...
X Description: Description ortho is broken and doesn't work as expected. I found other bug reports on this but they were >7 years old so I'm reposting, a lot has changed since then. Expected Behavior o...
Opengraph URL: https://github.com/processing/processing/issues/6175
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ortho broken (again) - suggested simple fix","articleBody":"## Description\r\northo is broken and doesn't work as expected. I found other bug reports on this but they were \u003e7 years old so I'm reposting, a lot has changed since then. \r\n\r\n## Expected Behavior\r\northo(0, width, 0, height), with a clear modelview matrix (resetMatrix), should enable the user to draw within the bounds specified.\r\n\r\n## Current Behavior\r\nIt doesn't work. Because of a bug in the ortho function (see below), this results in the user having to draw within (-height, 0) (all negative) to see. This is wrong and counterintuitive. \r\n\r\nOnline comments about people having to compensate because of some nonsense about left handed or right handed system, or processing's negative y, are blaming the user and proposing workarounds for a clear bug.\r\n\r\n## Steps to Reproduce\r\n```\r\nvoid setup() {\r\n size(500, 500, P3D);\r\n setupPOGL(); \r\n}\r\n\r\nvoid draw() {\r\n ortho(0, width, 0, height);\r\n resetMatrix(); // clear modelview matrix\r\n fill(255,255,255);\r\n //translate(0, -height); // fixes it\r\n beginShape(TRIANGLES);\r\n vertex(640, 640);\r\n vertex(0, 640);\r\n vertex(0, 0);\r\n endShape();\r\n}\r\n```\r\n\r\n\r\n\r\n## Your Environment\r\nWindows 10. Processing 3.5.4\r\n\r\n## Possible Causes / Solutions\r\n[https://github.com/processing/processing/blob/master/core/src/processing/opengl/PGraphicsOpenGL.java](url)\r\nLines 4493-4522 highlight the problem.\r\nNote line 4515 says: // The minus sign is needed to invert the Y axis.\r\nAnd then on line 4517 it's -y. What this does is to flip the y axis on zero. Not invert the y axis. This is why when the ortho isn't centered, it puts /all/ the y into the negative space.\r\n\r\nTo fix it is quite simple. To invert the y axis, you just invert the Y in NDC, /after/ the projection into NDC. This can be done by pre-multiplying the projection matrix with a -1 y scale. If you precalculate it, you can see that this can be fixed by simply putting a - also in front of the ty on line 4517\r\n\r\n```\r\n// This has a pre-multiplied -1 y scale to flip the y axis in NDC.\r\n projection.set(x, 0, 0, tx,\r\n 0, -y, 0, -ty,\r\n 0, 0, z, tz,\r\n 0, 0, 0, 1);\r\n```\r\n\r\nThis is rooted in Processing's unfortunate decision to have the Y axis going down to follow traditional computer coordinate systems. While that decision is defensible, the way it's implemented ad-hoc throughout is really frustrating for any serious graphics programmer. It really should have been added at the bottom level (in NDC or on the viewport), and exposed as a flag that someone could disable.\r\n\r\n","author":{"url":"https://github.com/usuallyannoyed","@type":"Person","name":"usuallyannoyed"},"datePublished":"2021-04-12T14:14:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/6175/processing/issues/6175"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a49873fb-e474-1fdf-0193-f25887d82b9e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E41E:326BEA:15BC010:1CD16A9:696F03B5 |
| html-safe-nonce | 843e9216bd5f2349645be1808d1be5fdaa178adee09083e388474ca3ca242410 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDFFOjMyNkJFQToxNUJDMDEwOjFDRDE2QTk6Njk2RjAzQjUiLCJ2aXNpdG9yX2lkIjoiNjIwMTY3NTMxMTA4MzM1NzEwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 11593f746fcfd667ae71609b4a02b6fe412923bf9bb7d450c2c6ec2faf38579d |
| hovercard-subject-tag | issue:856023039 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/processing/processing/6175/issue_layout |
| twitter:image | https://opengraph.githubassets.com/af1b8417fc06b3aaabf316caa9fec6ca7236d6d75773b4ebf2b8eb659e5220da/processing/processing/issues/6175 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/af1b8417fc06b3aaabf316caa9fec6ca7236d6d75773b4ebf2b8eb659e5220da/processing/processing/issues/6175 |
| og:image:alt | Description ortho is broken and doesn't work as expected. I found other bug reports on this but they were >7 years old so I'm reposting, a lot has changed since then. Expected Behavior ortho(0, wid... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | usuallyannoyed |
| hostname | github.com |
| expected-hostname | github.com |
| None | b278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee |
| turbo-cache-control | no-preview |
| go-import | github.com/processing/processing git https://github.com/processing/processing.git |
| octolytics-dimension-user_id | 1617169 |
| octolytics-dimension-user_login | processing |
| octolytics-dimension-repository_id | 7807399 |
| octolytics-dimension-repository_nwo | processing/processing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7807399 |
| octolytics-dimension-repository_network_root_nwo | processing/processing |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 39aed5006635ab6f45e6b77d23e73b08a00272a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width