From 370d29afd6b15ca4ef6afaf2b37e26ec25d7b991 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Wed, 16 Jan 2013 21:44:44 +0000 Subject: [PATCH] Added a couple of LWJGL examples --- .../examples/OffscreenTest/OffscreenTest.pde | 31 +++++++++++++++++++ .../examples/RestartTest/RestartTest.pde | 28 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 java/libraries/lwjgl/examples/OffscreenTest/OffscreenTest.pde create mode 100644 java/libraries/lwjgl/examples/RestartTest/RestartTest.pde diff --git a/java/libraries/lwjgl/examples/OffscreenTest/OffscreenTest.pde b/java/libraries/lwjgl/examples/OffscreenTest/OffscreenTest.pde new file mode 100644 index 000000000..31a666cf5 --- /dev/null +++ b/java/libraries/lwjgl/examples/OffscreenTest/OffscreenTest.pde @@ -0,0 +1,31 @@ +import processing.lwjgl.*; + +PGraphics pg; + +void setup() { + size(400, 400, LWJGL.P2D); + + pg = createGraphics(400, 400, LWJGL.P2D); + pg.smooth(4); +} + +void draw() { + background(0); + + pg.beginDraw(); + pg.background(255, 0, 0); + pg.ellipse(mouseX, mouseY, 100, 100); + pg.endDraw(); + + image(pg, 0, 0, 400, 400); +} + +void keyPressed() { + if (key == '1') pg.smooth(1); + else if (key == '2') pg.smooth(2); + else if (key == '3') pg.smooth(4); + else if (key == '4') pg.smooth(8); + else if (key == '5') pg.smooth(16); + else if (key == '6') pg.smooth(32); +} + diff --git a/java/libraries/lwjgl/examples/RestartTest/RestartTest.pde b/java/libraries/lwjgl/examples/RestartTest/RestartTest.pde new file mode 100644 index 000000000..7c0a40ae8 --- /dev/null +++ b/java/libraries/lwjgl/examples/RestartTest/RestartTest.pde @@ -0,0 +1,28 @@ +import processing.lwjgl.*; + +PShape cube; + +void setup() { + size(400, 400, LWJGL.P3D); + smooth(); + + cube = createShape(BOX, 100); +} + +void draw() { + background(120); + + lights(); + + translate(mouseX, mouseY); + rotateX(frameCount * 0.01f); + rotateY(frameCount * 0.01f); + + shape(cube); +} + +void keyPressed() { + // Changing the smooth configuration restarts the OpenGL surface. + // Automatically recreates all the current GL resources. + noSmooth(); +}