Created
March 3, 2020 20:49
-
-
Save companje/3ac4a6ff730dbeedd136f02d2b974e2a to your computer and use it in GitHub Desktop.
Rotating globe on DUAL 4K experiment performance test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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