Skip to content

Commit 1baac9d

Browse files
committed
Added a couple of LWJGL examples
1 parent 9fdfe3d commit 1baac9d

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import processing.lwjgl.*;
2+
3+
PGraphics pg;
4+
5+
void setup() {
6+
size(400, 400, LWJGL.P2D);
7+
8+
pg = createGraphics(400, 400, LWJGL.P2D);
9+
pg.smooth(4);
10+
}
11+
12+
void draw() {
13+
background(0);
14+
15+
pg.beginDraw();
16+
pg.background(255, 0, 0);
17+
pg.ellipse(mouseX, mouseY, 100, 100);
18+
pg.endDraw();
19+
20+
image(pg, 0, 0, 400, 400);
21+
}
22+
23+
void keyPressed() {
24+
if (key == '1') pg.smooth(1);
25+
else if (key == '2') pg.smooth(2);
26+
else if (key == '3') pg.smooth(4);
27+
else if (key == '4') pg.smooth(8);
28+
else if (key == '5') pg.smooth(16);
29+
else if (key == '6') pg.smooth(32);
30+
}
31+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import processing.lwjgl.*;
2+
3+
PShape cube;
4+
5+
void setup() {
6+
size(400, 400, LWJGL.P3D);
7+
smooth();
8+
9+
cube = createShape(BOX, 100);
10+
}
11+
12+
void draw() {
13+
background(120);
14+
15+
lights();
16+
17+
translate(mouseX, mouseY);
18+
rotateX(frameCount * 0.01f);
19+
rotateY(frameCount * 0.01f);
20+
21+
shape(cube);
22+
}
23+
24+
void keyPressed() {
25+
// Changing the smooth configuration restarts the OpenGL surface.
26+
// Automatically recreates all the current GL resources.
27+
noSmooth();
28+
}

0 commit comments

Comments
 (0)