/** * this demo shows how to use framebuffer objects */ import gestalt.p5.Ge; import processing.opengl.*; Ge.FBO fbo; float _myReScaleCounter; /* FBO size must be powers of two ( POT ) */ static final int FBO_WIDTH = 512; static final int FBO_HEIGHT = 256; void setup() { /* there are still issues with most window sizes */ size(1024, 768, OPENGL); Ge.setup(this); // Ge.fullscreen(true); fbo = Ge.fbo(FBO_WIDTH, FBO_HEIGHT); fbo.display().position().set(width / 2, height / 2); } void draw() { /* draw into window */ background(255, 0, 0); noStroke(); fill(255, 127, 0); rect(10, 10, width - 20, height - 20); stroke(255); line(0, 0, mouseX, mouseY); line(0, height, mouseX, mouseY); line(width, height, mouseX, mouseY); line(width, 0, mouseX, mouseY); /* draw into FBO */ fbo.bind(); background(255, 255, 0); fill(255); rect(10, 10, FBO_WIDTH - 20, FBO_HEIGHT - 20); stroke(0); line(0, 0, mouseX, mouseY); line(0, FBO_HEIGHT, mouseX, mouseY); line(FBO_WIDTH, FBO_HEIGHT, mouseX, mouseY); line(FBO_WIDTH, 0, mouseX, mouseY); fbo.unbind(); /* rescale FBO display */ fbo.display().scale().x = FBO_WIDTH + sin(_myReScaleCounter) * FBO_WIDTH * 0.2f; fbo.display().scale().y = FBO_HEIGHT + cos(_myReScaleCounter) * FBO_HEIGHT * 0.18f; /* we need to flip the display because * the gestalt coordinate system * starts in the lower left corner. */ fbo.display().scale().y *= -1; /* rotate FBO display */ fbo.display().rotation().x = _myReScaleCounter * 0.24f; fbo.display().rotation().y = _myReScaleCounter * 0.07f; _myReScaleCounter += 0.5f * 1f / frameRate; }