Isometric projection in PGraphicsOpenGL
in
Core Library Questions
•
2 years ago
I've been interested in isometric projection which I would like to achieve by manipulating the projection matrix. It works in P3D, but not in OPENGL (see code). I would like to refrain from native OpenGL calls, because they don't play nicely with regular Processing code. I would also like to refrain from Processing's ortho() function, since it's pretty shady. So the question is:
Is there a way to get isometric projection through the projection matrix in Processing's OpenGL?
Is there a way to get isometric projection through the projection matrix in Processing's OpenGL?
- import processing.opengl.*;
- PGraphics3D p3d ;
- PGraphicsOpenGL pgl;
- boolean opengl = false;
- void setup() {
- if (opengl) {
- size(500,500,OPENGL); // does not work :(
- pgl = (PGraphicsOpenGL) g;
- pgl.projection.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
- } else {
- size(500,500,P3D); // works
- p3d = (PGraphics3D) g;
- p3d.projection.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
- }
- camera(0,0,1000, 0,0,0, 0,1,0);
- noFill();
- stroke(255);
- }
- void draw() {
- background(0);
- rotateX(radians(45));
- rotateY(radians(45));
- box(1);
- }
3