/** * this demo shows how to use a processing sketch as a texture in gestalt. */ import gestalt.Gestalt; import gestalt.candidates.JoglFrameBufferCopy; import gestalt.p5.GestaltPlugIn; import gestalt.shape.Plane; import gestalt.shape.material.TexturePlugin; import gestalt.texture.bitmap.IntegerBitmap; import processing.opengl.*; GestaltPlugIn gestalt; Plane _myScreen; void setup() { /* setup p5 */ size(640, 480, OPENGL); rectMode(CENTER); gestalt = new GestaltPlugIn(this); /* * keep gestalt from clearing any buffers. * we do this after we copied the framebuffer into a texture */ gestalt.framesetup().depthbufferclearing = false; gestalt.framesetup().colorbufferclearing = false; /* create an empty dummy bitmap */ TexturePlugin myTexture = gestalt.drawablefactory().texture(); myTexture.load(IntegerBitmap.getDefaultImageBitmap(width, height)); /* create a plane to display our texture */ _myScreen = gestalt.drawablefactory().plane(); _myScreen.position().set(width / 2, height / 2); _myScreen.material().addPlugin(myTexture); _myScreen.scale().set(width, height); gestalt.bin(Gestalt.BIN_3D).add(_myScreen); /* create a screengrabber */ JoglFrameBufferCopy myFrameBufferCopy = new JoglFrameBufferCopy(myTexture); myFrameBufferCopy.backgroundcolor.set(0.2f, 1); myFrameBufferCopy.width = width; myFrameBufferCopy.height = height; gestalt.bin(Gestalt.BIN_3D_SETUP).add(myFrameBufferCopy); } void draw() { /* clear screen */ background(0, 128, 255); /* draw processing stuff */ fill(255, 255); stroke(0, 255); strokeWeight(20); rect(mouseX, mouseY, 200, 200); /* rotate gestalt canvas */ _myScreen.rotation().x += -0.0024f; _myScreen.rotation().y += 0.0063f; }