You can do it with a bit of OpenGL hacking (google for "opengl multiple viewport" or similar) but you'll also have to sort of fake out Processing's built-in draw loop mechanism to render twice. Something like this: (non-kosher hackery provided *AS IS*)
Quote:
import processing.opengl.*;
import javax.media.opengl.*;
GL gl;
float rotx, roty;
void setup() {
size(600,300,OPENGL);
colorMode(HSB);
}
void draw() {
background(0);
// left viewport - front view
g.beginDraw();
gl = ((PGraphicsOpenGL)g).beginGL();
gl.glViewport (0, 0, 300, 300);
((PGraphicsOpenGL)g).endGL();
perspective(PI/6f, 1f, 10, 1000);
camera(0,0,600, 0,0,0, 0,1,0);
renderGeometry();
g.endDraw();
// right viewport - back view
g.beginDraw();
gl = ((PGraphicsOpenGL)g).beginGL();
gl.glViewport(300, 0, 300, 300);
((PGraphicsOpenGL)g).endGL();
perspective(PI/6f, 1f, 10, 1000);
camera(0,0,-600, 0,0,0, 0,1,0);
renderGeometry();
g.endDraw();
}
void renderGeometry() {
lights();
rotateX(rotx);
rotateY(roty);
randomSeed(0);
for (int i=0; i<50; i++) {
float x = random(-100,100);
float y = random(-100,100);
float z = random(-100,100);
pushMatrix();
translate(x,y,z);
fill(random(256), 255, 255);
box(i+1);
popMatrix();
}
}
void mouseDragged() {
if (mouseButton==LEFT) {
float dx = mouseX-pmouseX;
float dy = mouseY-pmouseY;
rotx += -dy * 0.01;
roty += dx * 0.01;
}
}