Skip to content

Instantly share code, notes, and snippets.

@companje
Created March 3, 2020 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save companje/3ac4a6ff730dbeedd136f02d2b974e2a to your computer and use it in GitHub Desktop.
Save companje/3ac4a6ff730dbeedd136f02d2b974e2a to your computer and use it in GitHub Desktop.
Rotating globe on DUAL 4K experiment performance test
PGraphics pg;
PShape sphere, screen1, screen2;
float w=3840, h=w, hd2=h/2, wdh=w/h;
float distToCam = 1900;
void setup() {
fullScreen(OPENGL, SPAN);
pg = createGraphics((int)h, (int)h, OPENGL);
sphereDetail(100);
sphere = createShape(SPHERE, hd2);
sphere.setTexture(loadImage("earth8k.jpg"));
sphere.setStroke(false);
sphere.rotateY(HALF_PI);
sphereDetail(10);
screen1 = createShape();
screen1.setTexture(pg);
screen1.beginShape();
screen1.noStroke();
screen1.vertex(0, 0, 0, 0);
screen1.vertex(w, 0, w, 0);
screen1.vertex(w, hd2, w, hd2);
screen1.vertex(0, hd2, 0, hd2);
screen1.endShape(CLOSE);
screen2 = createShape();
screen2.setTexture(pg);
screen2.beginShape();
screen2.noStroke();
screen2.vertex(0, 0, 0, hd2);
screen2.vertex(w, 0, w, hd2);
screen2.vertex(w, hd2, w, h);
screen2.vertex(0, hd2, 0, h);
screen2.endShape(CLOSE);
}
void draw() {
pg.beginDraw();
pg.clear();
pg.perspective(atan(hd2/distToCam)*2, wdh, distToCam, 10000);
pg.camera(0, 0, -distToCam, 0, 0, 0, 0, 1, 0);
pg.scale(-1, 1, 1);
pg.rotateX(frameCount/100.);
pg.shape(sphere, 0, 0);
pg.endDraw();
background(100);
shape(screen1, 0, 0);
shape(screen2, 0, 0);
text(frameRate, 50, 50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment